I don't think it's the mysql query. Anyone have any ideas? The codebox isn't letting me add the code for some reason, so I'm unable to display what I have. I used the same code, just added a table to display the data. I like to do this outside of php tags, and insert them where needed. Could that be the problem?
pagination help
Started by thepoor666, Apr 01 2008 07:32 PM
2 replies to this topic
#1
Posted 01 April 2008 - 07:32 PM
#2
Posted 01 April 2008 - 09:49 PM
Post your code, It will be easier to help you then. Just type [code ][/code ] (No space between the "e" and "]")
dEcade
Should work
dEcade
#3
Posted 02 April 2008 - 06:34 AM
Here it is. I don't know why it wasn't working before. Oh, well.
<font color="#FFFFFF"><?php
if($_GET['page'])
{
$page = $_GET['page'];
}else{
$page = 1;
}
$max = 25;
$cur = (($page * $max) - $max);
mysql_select_db("products", $con);
$getdata = mysql_query("SELECT * FROM prods LIMIT $cur, $max") or die(mysql_error());
$data = mysql_fetch_array($getdata);
$counttotal = mysql_query("SELECT * FROM prods") or die(mysql_error());
$counttotal = mysql_num_rows($counttotal);
$total_pages = ceil($counttotal / $max);
?></font>
<table width="605" height="186" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="151" height="25" bgcolor="#666666"><font face="verdana" size="1" color="white"> <b>Product</b> </font> </td>
<td width="101" height="25" bgcolor="#666666"><font face="verdana" size="1" color="white"> <b>Price</b> </font> </td>
<td width="205" height="25" bgcolor="#666666"><font face="verdana" size="1" color="white"> <b>Description</b> </font> </td>
<td width="131" height="25" bgcolor="#666666"><font face="verdana" size="1" color="white"> <b>Add</b> </font> </td>
</tr>
<?php
{
?>
<tr>
<td width="151" height="25" bgcolor="#647977"><font face="verdana" size="1" color="#ffffff">
<?php
echo $data["itemName"]; ?>
<img src="<?php echo $data['path'];?>" width="125" height="125" /> </font> </td>
<td width="101" height="25" bgcolor="#647977"><font face="verdana" size="1" color="#FFFFFF"> <?php echo $data["itemPrice"]; ?> </font> </td>
<td width="205" height="25" bgcolor="#647977"><font face="verdana" size="1" color="#FFFFFF"> <?php echo $data["itemDesc"]; ?> </font> </td>
<td width="131" height="25" bgcolor="#647977"><a href="cart.php?action=add_item&id=<?php echo $data["itemId"]; ?>&qty=1"><font color="#FFFFFF">Add Item</font></a> </td>
</tr>
<?php
}
?>
<tr>
<td colspan="3"><font face="verdana" size="1" color="#FFFFFF"> <a href="cart.php"><font color="#FFFFFF">Your Shopping Cart >></font></a> </font> </td>
<td><?php
if($page > 1){
$prev = ($page - 1);
echo '<a href="?page=' . $prev . '"><font color="#FFFFFF">« Previous</font></a>';
}
for($i = 1; $i <= $total_pages; $i++)
{
if($page == $i)
{
echo'<b>' . $i .'</b> ';
} else {
echo '<a href="?page=' . $i . '"><font color="#FFFFFF">' . $i . '</font></a> ';
}
}
if($page < $total_pages){
$next = ($page + 1);
echo '<a href="?page=' . $next . '"><font color="#FFFFFF">Next »</font></a>';
}
?></td>
</tr>
</table>
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
