Hey all, I need some help with PHP code for paging my products on my site. I posted questions asking for help in the past, and was directed to
this tutorial for help. The code that the tutorial gives is great, but I'm having a hard time synchronizing it with my own code to make the whole thing work.
My goal is to take four basic product details:
$thumb (a thumbnail that will go along with its corresponding info)
$type (the 'type' of product)
$number (the serial number that identifies the product)
$desc (a short description of the product)
$thumb is the only non-varchar type. I haven't quite figured out how to implement pictures yet, but I'm receiving help for that in another thread. For right now I'm focusing on taking those four basic product details, listing 15 or 20 per page, and then adding a links at the bottom for any page after the first one fills up. My code to list the products works fine, now I just need to take those products and implement pagination.
Here's the code I wrote for querying the products on my page:
- <?php
-
include('books_login.php');
-
$connection=mysql_connect($mysql_host,$mysql_user,$mysql_password);
-
if(!$connection){
-
die("Could not connect to the database: <br/>". mysql_error());
-
}
-
$db_select=mysql_select_db($mysql_database);
-
if(!$db_select){
-
die("Could not select the database: <br/>".mysql_error());
-
}
-
$query="select * from air_registers";
-
$result=mysql_query($query);
-
if(!$result){
-
die("Could not query the database: <br/>". mysql_error());
-
}
-
while($row=mysql_fetch_array($result, MYSQL_ASSOC)){
-
$thumb=$row["Thumbnail"];
-
$type=$row["Type"];
-
$number=$row["Number"];
-
$desc=$row["Description"];
-
echo "$thumb";
-
echo "<div id='type'><strong>Model Type: </strong>$type</div>";
-
echo "<div id='number'><strong>Model #: </strong>$number</div>";
-
echo "<br />";
-
echo "<div id='desc'><strong>Description: </strong>$desc</div>";
-
echo "<br />";
-
echo "<hr>";
-
-
}
-
-
mysql_close($connection);
-
?>
Now
here is that paging code.
I've tried taking the paging code, and using bits and pieces to help my code, but I seem to mess it up everytime I tweak it. I can't get it to come out right. Any help is greatly appreciated. Thanks Bytes.