Forum Moderators: coopster

Message Too Old, No Replies

almost there. can some please take a look? <paged search results>

         

aludo325

3:56 pm on Jan 17, 2009 (gmt 0)

10+ Year Member



So i resolved my other problems (styling and target blank), but getting the script to return paged search results is not working.

With the script you see below, my results are listed, but the navigation (next, back) do not seem to work. I was hoping someone can look it over and tell me where I'm going wrong.

<?
$user="***********";
$password="************";
$database="*************";
mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
?>

<?
$increment = 3;
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;

$query="SELECT * FROM countries WHERE country_category='europe' LIMIT ";
$query .= $page * $increment - $increment . ", " . $increment;

$result = mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

echo "<b><center>Countries</center></b><br><br>";


while ($row = mysql_fetch_array($result))
{
echo '<a href="' . $row['country_link'] . '"target="_blank">' . $row['country_name'] . '<br /></a> ';
}

if($page > 1)
{
echo '<a href="' . $_SERVER['PHP_SELF'] . '?page=' . $page - 1 . '"> Back </a>';
}

echo '<a href="' . $_SERVER['PHP_SELF'] . '?page=' . $page + 1 . '"> Next</a>';

?>

eelixduppy

7:33 pm on Jan 17, 2009 (gmt 0)



My guess is that your problem is coming from the query itself however it looks OK to me. Can you echo out your query for me to see if it is being concatenated correctly.