ab123
04-30-2006, 04:18 PM
Ok i realy need to know why my search is not working correctly lol.....well it works it brings results but does not display pages..
the limit is 5 so it displays only 5 results...(i dont have much in db but i have more then 5 items)
Ok heres the code:
<?php
$searchin = $_GET[searchlink];
if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}
$max_results = 5;
$from = (($page * $max_results) - $max_results);
include('dbconfig.php');
$query="SELECT linkname, linkdes,
url FROM indexedlinks WHERE linkname LIKE '%$searchin%' LIMIT $from, $max_results";
$result=mysql_query($query); //already tryed .mysql_error() on all
while($srows=mysql_fetch_array($result)) {
$name = $srows[linkname];
$linkdisc = $srows[linkdes];
$url = $srows[linkurl];
echo "<table width=\"100%\" bgcolor=\"#ffffff\" cellspacing=\"2\" cellpadding=\"2\" border=\"1\">
<tr>";
echo "<td align=\"left\"><font color=\"#202020\" size=\"2\"> Site Name:</font></td>
<td align=\"left\"> ";
echo $sitename;
echo "</td></tr><tr>";
echo "<td align=\"left\"><font color=\"#202020\" size=\"2\"> Site Discription:</font></td>
<td align=\"left\"> ";
echo $linkdisc;
echo "</td></tr><tr>";
echo "<td align=\"left\"><font color=\"#202020\" size=\"2\"> Url:</font></td><td align=\"left\"> ";
echo "<a href=\"$url\" target=_blank\">$url</a>";
echo "</td></tr>";
echo "</table> <br><br>";
}
$total_results ="SELECT COUNT(*) as Num FROM thelinks";
$reso=mysql_query($total_results) or die(mysql_error());
$total_pages = ceil($total_results / $max_results);
echo "<center>Select a Page<br>";
if($page > 1){
$prev = ($page - 1);
echo "<a href=\"?page=$prev\"><<Previous</a> ";
}
for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i ";
} else {
echo "<a href=\"?page=$i\">$i</a> ";
}
}
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"?page=$next\">Next>></a>";
}
echo "</center>";
?>
the limit is 5 so it displays only 5 results...(i dont have much in db but i have more then 5 items)
Ok heres the code:
<?php
$searchin = $_GET[searchlink];
if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}
$max_results = 5;
$from = (($page * $max_results) - $max_results);
include('dbconfig.php');
$query="SELECT linkname, linkdes,
url FROM indexedlinks WHERE linkname LIKE '%$searchin%' LIMIT $from, $max_results";
$result=mysql_query($query); //already tryed .mysql_error() on all
while($srows=mysql_fetch_array($result)) {
$name = $srows[linkname];
$linkdisc = $srows[linkdes];
$url = $srows[linkurl];
echo "<table width=\"100%\" bgcolor=\"#ffffff\" cellspacing=\"2\" cellpadding=\"2\" border=\"1\">
<tr>";
echo "<td align=\"left\"><font color=\"#202020\" size=\"2\"> Site Name:</font></td>
<td align=\"left\"> ";
echo $sitename;
echo "</td></tr><tr>";
echo "<td align=\"left\"><font color=\"#202020\" size=\"2\"> Site Discription:</font></td>
<td align=\"left\"> ";
echo $linkdisc;
echo "</td></tr><tr>";
echo "<td align=\"left\"><font color=\"#202020\" size=\"2\"> Url:</font></td><td align=\"left\"> ";
echo "<a href=\"$url\" target=_blank\">$url</a>";
echo "</td></tr>";
echo "</table> <br><br>";
}
$total_results ="SELECT COUNT(*) as Num FROM thelinks";
$reso=mysql_query($total_results) or die(mysql_error());
$total_pages = ceil($total_results / $max_results);
echo "<center>Select a Page<br>";
if($page > 1){
$prev = ($page - 1);
echo "<a href=\"?page=$prev\"><<Previous</a> ";
}
for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i ";
} else {
echo "<a href=\"?page=$i\">$i</a> ";
}
}
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"?page=$next\">Next>></a>";
}
echo "</center>";
?>