dynamic columns
| From: | olinux | Date: | Fri, 16 Mar 2001 21:42:44 +0000 |
| Subject: | dynamic columns | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-7554@lists.php.net to get a copy of this message | ||
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