Time for a slightly less-newbie question than before from me. Believe me,
I've RTF'nM and I'm *not* getting this. :(
So I am currently displaying all products from one product category:
$sql2="select * FROM products WHERE prod_cat = $cat_ID";
$mysql_result=mysql_query($sql2,$connection);
$num_rows=mysql_num_rows($mysql_result);
if ($num_rows==0){
echo "no results";
} else {
while ($row=mysql_fetch_array($mysql_result)){
$prod_name=$row["prod_name"];
$prod_image=$row["prod_image"];
$prod_ID=$row["ID"];
echo "<img src=\"products/$prod_image\" border=0
height=150><br>$prod_name<br><br>";
}
}
What I'm trying to do is have the ability to page through the database just
4 products at a time. (This is a regular online catalog and I'm just trying
to have a "next 4 products" link on the category page.) I know how to
display only 4 products. What I can't figure out is to remember where I was
in displaying them. I'm thinking "array" here... but the arrays we
typically get are of the fields in the database, not the rows. I want an
array that stores all the rows, not all the fields. What am I missing?
The logic I've come up with is to do this:
$sql2="select * FROM products WHERE prod_cat = $cat_ID";
$mysql_result=mysql_query($sql2,$connection);
$num_rows=mysql_num_rows($mysql_result);
if ($num_rows==0){
echo "no results";
} else {
while ($row=mysql_fetch_array($mysql_result)){
// 1) create an array of all the product_id's in the result (one from
each
row)
// 2) then select product_id 4 at a time and display them on the page
// ... but that'd be a buttload of db hits
}
}
I can't even quite figure out the logic here. If anybody is interested in
simply pointing me in the right direction, like say, "Jen, don't you know
about mysql_fetch_jen's_type_of_array?!" then perhaps I can figure it out
from there. Thank you very much in advance.
Jen Swofford
[EMAIL PROTECTED]
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php