no, let me explain: (hope it makes sense)
well, i found some code on pagination and tried to implement it into my code and the result is this:
I type in what to search for and i get the results i want from the database. When i click next, it shows me the results I had in the beginning and not the results i typed into the search. Also, my other links won't work. At first i thought it was a problem with my queries but i guess not. So I really don't know where the problem is. I put my code up so you guys can see what i've done
Here's ALL the php code:
NEW SEARCH CODE:
<?php
// set your infomation.
$dbhost='localhost:3306';
$dbusername='limao';
$dbuserpass='password';
$dbname = 'CCTVPRODUCTS';
// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
//select the database
mysql_select_db($dbname) or die('Cannot select database');
if(isset($_GET['search']))
{
$search = $_GET['search'];
}
$keywords = explode(" ", $search);
// If current page number, use it
// if not, set one!
if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}
// Define the number of results per page
$max_results = 4;
// Figure out the limit for the query based
// on the current page number.
$from = (($page * $max_results) - $max_results);
$query = "SELECT * FROM colorcameras
WHERE camDescription LIKE '%".$keywords['0']."%'LIMIT $from, $max_results";
$result = mysql_query($query) or die(mysql_error());
?>
NEW RESULTS CODE:
<?php
echo "<tr>";
echo '<td width="156" align="center" height="20" bgcolor="#446F9D" style="border-right: 1px solid #FFFFFF; border-bottom: 1px solid #FFFFFF">';
echo '<p align="center" style="margin-top: 0; margin-bottom: 0">'.'<b><font face="Verdana" size="2" color="#FFFFFF">'.camera.'</font></b>';
echo '<td width="156" align="center" height="20" bgcolor="#446F9D" style="border-right: 1px solid #FFFFFF; border-bottom: 1px solid #FFFFFF">';
echo '<p align="center" style="margin-top: 0; margin-bottom: 0">'.'<b><font face="Verdana" size="2" color="#FFFFFF">'.Description.'</font></b>';
echo '<td width="156" align="center" height="20" bgcolor="#446F9D" style="border-right: 1px solid #FFFFFF; border-bottom: 1px solid #FFFFFF">';
echo '<p align="center" style="margin-top: 0; margin-bottom: 0">'.'<b><font face="Verdana" size="2" color="#FFFFFF">'.Supplier.'</font></b>';
echo '<td width="156" align="center" height="20" bgcolor="#446F9D" style="border-right: 1px solid #FFFFFF; border-bottom: 1px solid #FFFFFF">';
echo '<p align="center" style="margin-top: 0; margin-bottom: 0">'.'<b><font face="Verdana" size="2" color="#FFFFFF">'.Website.'</font></b>';
echo '</td>';
echo '</tr>';
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo '<td width="156" align="center" height="24" bgcolor="#5785B3" style="border-right: 1px solid #FFFFFF; border-bottom: 1px solid #FFFFFF">';
echo '<p align="center" style="margin-top: 0; margin-bottom: 0">'.'<br><b><font face="Verdana" size="1" color="#FFFFFF">'.$row['camName'].'</font></b>';
echo '<td width="156" align="center" height="24" bgcolor="#5785B3" style="border-right: 1px solid #FFFFFF; border-bottom: 1px solid #FFFFFF">';
echo '<p align="center" style="margin-top: 0; margin-bottom: 0">'.'<br><b><font face="Verdana" size="1" color="#FFFFFF">'.$row['camDescription'].'</font></b>';
echo '<td width="156" align="center" height="24" bgcolor="#5785B3" style="border-right: 1px solid #FFFFFF; border-bottom: 1px solid #FFFFFF">';
echo '<p align="center" style="margin-top: 0; margin-bottom: 0">'.'<br><b><font face="Verdana" size="1" color="#FFFFFF">'.$row['camSupplier'].'</font></b>';
echo '<td width="156" align="center" height="24" bgcolor="#5785B3" style="border-right: 1px solid #FFFFFF; border-bottom: 1px solid #FFFFFF">';
echo '<p align="center" style="margin-top: 0; margin-bottom: 0">'.'<br><b><font face="Verdana" size="1" color="#FFFFFF">
<a href="'.$row['website'].'">'.$row['website'].'</a></font></b>';
echo '</td>';
echo '</tr>';
}
// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM colorcameras"),0);
// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);
// Build Page Number Hyperlinks
echo "<center>Select a Page<br />";
// Build Previous Link
if($page > 1){
$prev = ($page - 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> ";
}
for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i ";
} else {
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
}
}
// Build Next Link
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>";
}
?>
Thats ALL the php code, if anyone can help me learn and understand how to proceed with this i would appreciate it. thank you!
p.s. I'm an extreme newbie aka been doin and learning this for less than a month