RE: [PHP-DB] dynamic columns

From: Date: Fri, 16 Mar 2001 22:17:56 +0000
Subject: RE: [PHP-DB] dynamic columns
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-7555@lists.php.net to get a copy of this message
Are the fields always the same? Ive used something similar, I usually fill an array with selection ids when while loop them into querys-> To get the table I ussualy create a container table(one cell) and generate tables inside the container one for each item. -----Original Message----- From: olinux [mailto:olnx@yahoo.com] Sent: Friday, March 16, 2001 1:43 PM To: PHP-DB; PHPLearners@egroups.com Subject: [PHP-DB] dynamic columns Greetings, I would like to put together a script that results similar to www.bestbuy.com 's compare feature. Basically if you are looking in an item category you can select check boxes for each item you would like to compare. The results display like this; ITEM 1 ITEM 2 ITEM 3 FIELD1 FIELD2 FIELD3 So the problem for me in creating this is, how do you accomodate for sometimes 2 items, and sometimes 3 or 4 being selected? It would be easy to show the table reversed (with fields at the top), but i like the way it is. I have thought about it and wonder if something like this would work. (my code will be sloppy... but just to give an idea) SELECT * FROM item_table WHERE item_ID = \"$item_ID\" This would grab all of the records for the item ID's passed [which are passed from the checkboxes] We would also need to get the field names. I will assume that we have these. And then we need to use a while loop to get all variables. Now we need to display it. The following would go at the end of the while loop /* $item_1_1 indicates the property of item 1 that corresponds to field_1 Thus, $item_1_2 indicates the property of item 1 that corresponds to field_2 */ /* Now here we put an if statement that counts the number of records that were displayed and doe something based on that number */ $comparison_table = " <TR> <TD>$field_1</TD> <TD>$item_1_1</TD>"; I don't know! Now I am lost, please help me if you can. Thanks olinux

« previous php.db (#7555) next »