mat
09-12-2002, 08:59 AM
Hi,
I'm making a product gallery, It's job is to pull out the matching products for that particular collection/product range and display them on the page in 2 rows, 3 to a row max.
this is an bare bones example (http://www.orchid.f2o.org/php_test/output.php?collection=1) in progress
So this dynamic gallery is fine if i have 6 or less products returned but if i have anymore, how can i make it so that instead of just outputting them down the page (i only want 2 rows of 3 per page) it outputs a next link and makes a new page?
the code for m example linked above is below:
<?php
include "dbConnect.php";
$sql = "SELECT p.potID, p.potName, p.image, c.collectionID
FROM pots p, collection c
WHERE p.collection = c.collectionID
AND $collection = c.collectionID ";
$result = mysql_query($sql);
$pictures="";
echo ("
<table border=\"1\" width=\"630\" height=\"600\">
<tr height=\"90\" width=\"630\">
<td height=\"90\" colspan=\"3\">
nav
<td>
</tr>
<tr>
");
$currentDone = $totalDone = 0;
while ($row = mysql_fetch_array($result)){
$potName = $row['potName'];
$pic = $row['image'];
$potID = $row['potID'];
if ($currentDone == 3){
$pictures .="
</tr>
<tr >";
}
$pictures .="
<td height=\"200\" width=\"210\">
<table align=\"center\" border=\"1\" width=\"160\">
<tr>
<td colspan=\"2\"><img src=\"{$pic}_small.jpg\"></td>
</tr>
<tr>
<td><A HREF='detail.php?pot=$potID' target='popup' onClick=\"window.open('detail.php?pot=$potID','popup','width=300,height=500'); return false\">Detail</a></td>
<td>1</td>
</tr>
</table>
</td> ";
$currentDone ++;
$totalDone ++;
}
if ($totalDone == 0) $pictures ="Nothing returned";
echo $pictures;
echo ("
<tr height=\"100%\">
<td colspan=\"3\"> </td>
</tr>
</tr>
</table>
");
?>
I have spotted 2 tutorials on this but they seem a bit complicated, I wonder if it can be done simply (so i can understand). something like
if totalDone == 6
then output a next link
and generate a new page to display the rest of the products
on the new page display a previous link etc..
Simple way of doing it?, i'd appreciate some help :)
I'm making a product gallery, It's job is to pull out the matching products for that particular collection/product range and display them on the page in 2 rows, 3 to a row max.
this is an bare bones example (http://www.orchid.f2o.org/php_test/output.php?collection=1) in progress
So this dynamic gallery is fine if i have 6 or less products returned but if i have anymore, how can i make it so that instead of just outputting them down the page (i only want 2 rows of 3 per page) it outputs a next link and makes a new page?
the code for m example linked above is below:
<?php
include "dbConnect.php";
$sql = "SELECT p.potID, p.potName, p.image, c.collectionID
FROM pots p, collection c
WHERE p.collection = c.collectionID
AND $collection = c.collectionID ";
$result = mysql_query($sql);
$pictures="";
echo ("
<table border=\"1\" width=\"630\" height=\"600\">
<tr height=\"90\" width=\"630\">
<td height=\"90\" colspan=\"3\">
nav
<td>
</tr>
<tr>
");
$currentDone = $totalDone = 0;
while ($row = mysql_fetch_array($result)){
$potName = $row['potName'];
$pic = $row['image'];
$potID = $row['potID'];
if ($currentDone == 3){
$pictures .="
</tr>
<tr >";
}
$pictures .="
<td height=\"200\" width=\"210\">
<table align=\"center\" border=\"1\" width=\"160\">
<tr>
<td colspan=\"2\"><img src=\"{$pic}_small.jpg\"></td>
</tr>
<tr>
<td><A HREF='detail.php?pot=$potID' target='popup' onClick=\"window.open('detail.php?pot=$potID','popup','width=300,height=500'); return false\">Detail</a></td>
<td>1</td>
</tr>
</table>
</td> ";
$currentDone ++;
$totalDone ++;
}
if ($totalDone == 0) $pictures ="Nothing returned";
echo $pictures;
echo ("
<tr height=\"100%\">
<td colspan=\"3\"> </td>
</tr>
</tr>
</table>
");
?>
I have spotted 2 tutorials on this but they seem a bit complicated, I wonder if it can be done simply (so i can understand). something like
if totalDone == 6
then output a next link
and generate a new page to display the rest of the products
on the new page display a previous link etc..
Simple way of doing it?, i'd appreciate some help :)