Re: formatting logic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am allowing our members to upload pictures and they can choose which category the pictures go under, the first category "public" is made for them.

When I sql the DB I call it like this: select picture_names<,more fields> from <table> where member_id=<x> order by category.

which i display something like this:
__________________________________
| pic-here | <some text here> | category here|
| pic-here | <some text here> | category here|
---------------------------------------------

how can i display it like this:

__________________________________
category here                                                |
---------------------------------------------
| pic-here | <some text here>                         |
| pic-here | <some text here>                         |
__________________________________
category here                                                |
---------------------------------------------
| pic-here | <some text here>                         |
| pic-here | <some text here>                         |
---------------------------------------------

I thought of just getting the categories into an array and then sqling on each category but if there are 30 user defined categories that would mean 30 queries.... Another more complicated way would be to get all the records and sort them into arrays via categories and child arrays...I just feel this is too complicated for the above job.

Keep your query like it is... and do something like this:

$current_category = "";

while ( $row = db_get_object_function($db_result) ) {
	if ($current_category != $row->category) {
		print("$row->category header goes here");
		$current_category = $row->category;
	}
	print("pic-here stuff goes here");
}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux