1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
<?php require_once($LIBPATH . "utilfunc.php"); require_once("../conf_/siteconf_.php"); require_once("../admin/dbconn.php"); if($dbConn) { $self="index.php?pg=rezultate&ord=".$_GET['ord']; // If you use this code with a different page ( or file ) name then change this // how many rows to show per page $rowsPerPage = 5; // by default we show first page $pageNum = 1; // if $_GET['page'] defined, use it as page number if(isset($_GET['page'])) { $pageNum = $_GET['page']; } // counting the offset $offset = ($pageNum - 1) * $rowsPerPage; if ((isset($_GET['ord'])) && (($_GET['ord']) != "")) { $sql_all = 'SELECT * FROM articles WHERE ((SUBSTRING(NameRO, 1, 1) = "'.$_GET['ord'].'") AND (NameRO like '%$_POST[term]%' OR ContentRO like '%$_POST[term]%')) ORDER BY OrderID'; } else { $sql_all = "SELECT * FROM articles WHERE (NameRO like '%$_POST[term]%' OR ContentRO like '%$_POST[term]%') ORDER BY NameRO AND OrderID"; } $result_all = @mysql_query($sql_all); $num_rows = mysql_num_rows($result_all); if ((isset($_GET['ord'])) && (($_GET['ord']) != "")) { $sql = 'SELECT * FROM articles WHERE (SUBSTRING(NameRO, 1, 1) = "'.$_GET['ord'].'" AND (NameRO like '%$_POST[term]%' OR ContentRO like '%$_POST[term]%')) ORDER BY OrderID limit ' . $offset. ', '. $rowsPerPage; } else { $sql = "SELECT * FROM articles WHERE (NameRO like '%$_POST[term]%' OR ContentRO like '%$_POST[term]%') ORDER BY NameRO AND OrderID limit $offset, $rowsPerPage"; } $result = @mysql_query($sql); $numnow_rows = mysql_num_rows($result); $articles = ""; if ($numnow_rows == 0) { $articles = "<tr><td align=\"center\" height=\"35\" style=\"padding:10px;\">Nici un rezultat cu textul: <b>".$_POST['term'].".</b></td></tr>"; } else { $articles .= "<section>"; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $articleImage = ""; if ($row['ImgID'] !== "") $articleImage .= ' <div> <a href="index.php?pg=articol&id=' . $row['ID'] . '"> <img class="article_image" src="../images/articole/' . $row['ImgID'] .'" alt=""> </a> </div>';
$articles .= ' <article> <div class="content"> <div> <b>' . $row['NameRO'] . '</b> <br> ' . substr(strip_tags($row['ContentRO']), 0, 300) . ' <br> <a href="index.php?pg=articol&id=' . $row['ID'] . '">mai mult...</a> </div> ' . $articleImage . ' </div> <hr> </article>'; } $articles .= "</section>"; // how many pages we have when using paging? $maxPage = ceil($num_rows/$rowsPerPage); // creating 'previous' and 'next' link // plus 'first page' and 'last page' link // print 'previous' link only if we're not // on page one if ($pageNum > 1) { $page = $pageNum - 1; $prev = " <a href=\"$self&page=$page\">[Anterioara]</a> "; $first = " <a href=\"$self&page=1\">[Prima]</a> "; } else { $prev = '<span>[Anterioara]</span>'; // we're on page one, don't enable 'previous' link $first = '<span>[Prima]</span>'; // nor 'first page' link } // print 'next' link only if we're not // on the last page if ($pageNum < $maxPage) { $page = $pageNum + 1; $next = " <a href=\"$self&page=$page\">[Urmatoare]</a> "; $last = " <a href=\"$self&page=$maxPage\">[Ultima pagina]</a> "; } else { $next = '<span>[Urmatoare]</span>'; // we're on the last page, don't enable 'next' link $last = '<span>[Ultima pagina]</span>'; // nor 'last page' link } // print the page navigation link $articles .= " <section id=\"pagination\"> <div>" . $first . $prev . "</div> <div> Pagina <strong>$pageNum</strong> din <strong>$maxPage</strong> pagini </div> <div>" . $next . $last."</div> </section>"; } //mysql_free_result($result); } $title .=""; ?>
<main class="page"> <section class="adr2 breadcrumbs"><a href="index.php" class="adr2">Home</a> » Legende Rock</section>
<?= $articles; ?>
</main>
|