Re: [PHP]DB Logic help...

2001-07-31 Thread Richard Lynch

 I have a few pages on my website which need to be divided up into
different
 columns and rows based on a category in a table. for example, on a links
 page, I have three different columns, one for bands, one for sites, and
one
 for other things. I'm storing those things in the table with a category
 field, so that when I output the data, it goes to the right place. However
 I'm a little unsure of the actual code to do this...

Assuming it's not critical to line up, say, the third band with the third
site in your table, right?

So all you really need is three columns with line breaks BR between
individual bands/sites/things:

TABLETR
?php
# Let the database sort out all our data for us, which is what databases
are good at:
$query = select id, category, name from stuff GROUP BY category order
by name;
$stuff = mysql_query($query) or die(mysql_error());

# We'll be tracking which category we are on with this variable:
$last_category = '';

# Go through all the data:
while (list($id, $category, $name) = mysql_fetch_row($stuff)){
if ($category != $last_category){
# End previous column, if there was one ($last_category):
if ($last_category){
echo /TD\n;
}
# Start a new column for the new category:
echo TDB$category/BBR\n;

# Remember which category we are on now:
$last_category = $category;
}

# Spew out an individual item:
echo A HREF=http://details.php?id=$id$name/ABR\n;
}
# Finish off that final column:
echo /TD\n;
?
/TR/TABLE

--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP]DB Logic help...

2001-07-30 Thread Chris Cocuzzo

hey-

I have a few pages on my website which need to be divided up into different
columns and rows based on a category in a table. for example, on a links
page, I have three different columns, one for bands, one for sites, and one
for other things. I'm storing those things in the table with a category
field, so that when I output the data, it goes to the right place. However
I'm a little unsure of the actual code to do this...

can someone lend me an example or give me some ideas?

thanks
chris



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP]DB Logic help...

2001-07-30 Thread B. van Ouwerkerk

Seen some stuff on freshmeat. Does about what you want.

Bye,


B.

At 14:27 30-7-01 -0400, Chris Cocuzzo wrote:
hey-

I have a few pages on my website which need to be divided up into different
columns and rows based on a category in a table. for example, on a links
page, I have three different columns, one for bands, one for sites, and one
for other things. I'm storing those things in the table with a category
field, so that when I output the data, it goes to the right place. However
I'm a little unsure of the actual code to do this...

can someone lend me an example or give me some ideas?

thanks
chris



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]