[thelist] help w/design of SQL query
Tom Dell'Aringa
pixelmech at yahoo.com
Fri Nov 15 11:25:01 CST 2002
--- Kelly Hallman <khallman at wrack.org> wrote:
> Try this:
>
> $lastcat = "";
> while($row = mysql_fetch_array($result)) {
> $category = $row["category"];
> $item = $row["item"];
> $price = $row["price"];
> if ($category != $lastcat) {
> echo "Category: $category\n"; }
> print "Item: $item -- Price: $price\n";
> }
>
> Your code was setting some values before any rows were fetched.
> Compare
> the two and you should see the difference. Good luck!
doh! (slaps head). Ok, this is CLOSE to what I wanted. It prints the
category out and then the item. I think I didn't state this right - I
only want to print the category out ONCE - then print out the related
items. I only want:
Category:
Item in cat
item in cat
item in cat
Do I have to go back to the SQL for this or the PHP?
Tom
=====
var me = tom.pixelmech.webDeveloper();
http://www.pixelmech.com/
http://www.maccaws.com/
[Making A Commercial Case for Adopting Web Standards]
__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com
More information about the thelist
mailing list