zoekscript...
je hebt een next en previous link, maar die links doen het niet...echt raar...
weet iemand het misschien ?
link: http://www.addrenaline.com/~ip-03/test/
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
Code (php)
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
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
<?php
include("includes/header.php");
class Pager
{
function getPagerData($numHits, $limit, $page)
{
$numHits = (int) $numHits;
$limit = max((int) $limit, 1);
$page = (int) $page;
$numPages = ceil($numHits / $limit);
$page = max($page, 1);
$page = min($page, $numPages);
$offset = ($page - 1) * $limit;
$ret = new stdClass;
$ret->offset = $offset;
$ret->limit = $limit;
$ret->numPages = $numPages;
$ret->page = $page;
return $ret;
}
}
?>
include("includes/header.php");
class Pager
{
function getPagerData($numHits, $limit, $page)
{
$numHits = (int) $numHits;
$limit = max((int) $limit, 1);
$page = (int) $page;
$numPages = ceil($numHits / $limit);
$page = max($page, 1);
$page = min($page, $numPages);
$offset = ($page - 1) * $limit;
$ret = new stdClass;
$ret->offset = $offset;
$ret->limit = $limit;
$ret->numPages = $numPages;
$ret->page = $page;
return $ret;
}
}
?>
<table width="60%" border="0">
<tr>
<td><img src="banner_bedrijf_pago.jpg"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width="100%" height="64" border="0">
<tr>
<td>
<script language="JavaScript" src="http://www.addrenaline.com/~ip-03/test/js/menu.js"></script>
<noscript>Your browser does not support script</noscript>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width="650" class="kant">
<tr>
<td>Zoekresultaten: <b></b></td>
</tr>
<tr>
Code (php)
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
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
<?php
include("includes/config.php");
if ( isset($_POST["trefwoord"]) && $_POST["trefwoord"] != "")
{
$trefwoord = explode(" ", $_POST["trefwoord"]);
$where_query = "";
foreach( $trefwoord as $value)
{
$where_query .= empty($where_query) ? " WHERE " : " OR ";
$where_query .= " nieuws_id LIKE '%$value%' OR titel LIKE '%$value%' OR omschrijving LIKE '%$value%' ";
}
// get the pager input values
$page = $_GET['page'];
$limit = 10;
$result = mysql_query("select count(*) from nieuws");
$total = mysql_result($result, 0, 0);
// work out the pager values
$pager = Pager::getPagerData($total, $limit, $page);
$offset = $pager->offset;
$limit = $pager->limit;
$page = $pager->page;
// use $result here to output page content
$query = "SELECT nieuws_id, titel, omschrijving, DATE_FORMAT(datum, '%d-%m-%Y ') AS datum from nieuws".$where_query;
$query .= " ORDER BY `titel` ASC LIMIT 0, 10";
$resultaat = mysql_query($query) or die("SQL Error: " . mysql_error());
while($data = mysql_fetch_array($resultaat))
{
if (strlen($data['omschrijving']) > 220){
$data['omschrijving'] = substr($data['omschrijving'], 0, 100) . "...";}
// onderwerp in korten als het de zin te lang is.
$ltitel = $data['titel'] ;
if (strlen($data['titel']) > 35){
$data['titel'] = substr($data['titel'], 0, 40) . "...<a href='nieuws/nieuws.php?nieuws_id=" . $data['nieuws_id'] . "'></a><br>";}
echo mysql_error();
?>
include("includes/config.php");
if ( isset($_POST["trefwoord"]) && $_POST["trefwoord"] != "")
{
$trefwoord = explode(" ", $_POST["trefwoord"]);
$where_query = "";
foreach( $trefwoord as $value)
{
$where_query .= empty($where_query) ? " WHERE " : " OR ";
$where_query .= " nieuws_id LIKE '%$value%' OR titel LIKE '%$value%' OR omschrijving LIKE '%$value%' ";
}
// get the pager input values
$page = $_GET['page'];
$limit = 10;
$result = mysql_query("select count(*) from nieuws");
$total = mysql_result($result, 0, 0);
// work out the pager values
$pager = Pager::getPagerData($total, $limit, $page);
$offset = $pager->offset;
$limit = $pager->limit;
$page = $pager->page;
// use $result here to output page content
$query = "SELECT nieuws_id, titel, omschrijving, DATE_FORMAT(datum, '%d-%m-%Y ') AS datum from nieuws".$where_query;
$query .= " ORDER BY `titel` ASC LIMIT 0, 10";
$resultaat = mysql_query($query) or die("SQL Error: " . mysql_error());
while($data = mysql_fetch_array($resultaat))
{
if (strlen($data['omschrijving']) > 220){
$data['omschrijving'] = substr($data['omschrijving'], 0, 100) . "...";}
// onderwerp in korten als het de zin te lang is.
$ltitel = $data['titel'] ;
if (strlen($data['titel']) > 35){
$data['titel'] = substr($data['titel'], 0, 40) . "...<a href='nieuws/nieuws.php?nieuws_id=" . $data['nieuws_id'] . "'></a><br>";}
echo mysql_error();
?>
<td>
<img src="blokje.jpg" width="10" height="10">
<a href="nieuws/nieuws.php?nieuws_id="><b></b></a><br>
Toegevoegd op:
</td>
</tr>
<tr>
<td width="315" align="left" valign="top">
</td>
</tr>
<tr>
<td> </td>
</tr>
Code (php)
<tr>
<td>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
// output paging system (could also do it before we output the page content)
if ($page == 1) // this is the first page - there is no previous page
echo "Previous";
else // not the first page, link to the previous page
echo "<a href=\"zoeken.php?page=" . ($page - 1) . "\">Previous</a>";
for ($i = 1; $i <= $pager->numPages; $i++) {
echo " | ";
if ($i == $pager->page)
echo "Page $i";
else
echo "<a href=\"zoeken.php?page=$i\">Page $i</a>";
}
if ($page == $pager->numPages) // this is the last page - there is no next page
echo "Next";
else // not the last page, link to the next page
echo "<a href=\"zoeken.php?page=" . ($page + 1) . "\">Next</a>";
?>
// output paging system (could also do it before we output the page content)
if ($page == 1) // this is the first page - there is no previous page
echo "Previous";
else // not the first page, link to the previous page
echo "<a href=\"zoeken.php?page=" . ($page - 1) . "\">Previous</a>";
for ($i = 1; $i <= $pager->numPages; $i++) {
echo " | ";
if ($i == $pager->page)
echo "Page $i";
else
echo "<a href=\"zoeken.php?page=$i\">Page $i</a>";
}
if ($page == $pager->numPages) // this is the last page - there is no next page
echo "Next";
else // not the last page, link to the next page
echo "<a href=\"zoeken.php?page=" . ($page + 1) . "\">Next</a>";
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</center>
</td>
Gewijzigd op 15/11/2004 13:45:00 door Robert
up