|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Next result by Limit
Please, can some one tell me whats wrong with this script. Why dont the next 10 rows of the search result shows.
How can i make this work. <? if ($searchstring) { if (!isset($start)) $start = 0; include("common.php"); $link = dbConnect(); $query ="SELECT kundid, icon, namn, typ FROM $table WHERE namn LIKE '%$searchstring%' LIMIT $start , 10"; $result = mysql_query($query) or die(mysql_error()); ?> <br> <table border="0" width="200" cellpadding="0" cellspacing="0"> <? while ($raden = mysql_fetch_array($result)){ echo "<tr bgcolor=#cccccc> <td width=20><img src='$raden[icon]' width=20 height=20></td> <td><font face=verdana size=2> <b><a href=info.php?kundid=$raden[kundid]>$raden[namn]</a></b></font></td> <td><font face=verdana size=1>$raden[typ]</font></td> </tr> <tr height=2 bgcolor=#ffffff> <td colspan=3> </td> </tr>"; } ?> <tr><td colspan=3> <? $query = "SELECT count(*) as count FROM $table WHERE namn LIKE '%$searchstring%' LIMIT $start , 10"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); $numrows = $row['count']; if($start > 0){ echo "<a href="" . $PHP_SELF . "?start=" . ($start - 10) . "">Previous</a><BR>n"; } if($numrows > ($start + 10)){ echo "<a href="" . $PHP_SELF . "?start=" . ($start + 10) . "">Next</a><BR>n"; } ?> </td></tr> </table> <? } ?> |
|
#2
|
|||
|
|||
|
RE: Next result by Limit
|
|
#3
|
|||
|
|||
|
RE: Next result by Limit
what version of php are you using??
after the <?php tag, add this line in $start = $_GET['start']; |
|
#4
|
|||
|
|||
|
RE: Next result by Limit
Thanks for your help.
The problem was in the link. Now it looks like this. echo "<a href="" . $PHP_SELF . "?start=" . ($start + 10) . "&searchstring=" . ($searchstring) . "">Next</a> |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Next result by Limit |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|