This isn't going to be the most helpful answer, because I'm wondering why
you'd want to do this in the first place.
All you really have to do is create a new array from the existing result
set, transposing the columns.
The number of elements in the array will be the number of car_ID's that are
returned, the number of rows in the array will equal the number of
attributes (columns) in the result set.
Stepping through the result set and building the new array will be a rather
interesting exercise in nested loops as you will be repeatedly going
through the results set for each of ID, make, model, and color.
After this array is built, then I'd worry about displaying it.
Before that, however:
Is it so important that the order of display be rearranged? Really,
what's the difference?
What if 8 cars are returned instead of 3? What if 20? Your table will
blow out to the right, something users don't like.
How do you plan to have users select the cars they want more
information about?
Only you can answer these, and maybe you have. In which case, good luck.
Miles Thompson
At 07:52 PM 3/22/01 -0800, olinux wrote:
>I would like to make a comparison script that will compare two items. Here
>is an example and my "halfway" there solution. [at least i think so
>
>Here is my table [for the sake of this example]
>
>+---------------------------------------------------------+
>| car_ID | make | model | color |
>+---------------------------------------------------------+
>| | | | |
>| | | | |
>| | | | |
>| | | | |
>|________|_________|________|________|
>
>
>I would like the user to be able to select two or more cars to be compared
>[these will be passed from an html form as car_ID
>Table will be laid out something like this.
>
>+---------------------------------------------------------+
>| | Car 1 | Car 2 | Car 3 |
>+---------------------------------------------------------+
>| car_ID | 123 | 234 | 345 |
>+---------------------------------------------------------+
>| make | honda | honda | ford |
>+---------------------------------------------------------+
>| model | civic | civic | tempo |
>+---------------------------------------------------------+
>| color | black | blue | red |
>+---------------------------------------------------------+
>
>basically the table is just displayed with fields and records transversed
>[switched]
>
>Now i select the info for the two cars, and $result holds the finished query
>
>OK now to display it.
>
>the first while loop will write the rows.
>
>$table = "<TR>";
>
>while ($row = mysql_fetch_array($result)) {
> $carID = $row['carID'];
> $make = $row['make'];
> $model = $row['model'];
> $color = $row['color'];
>
>$table .= "<TD>Car ID</TD><TD>$car_ID[1]</TD>";
>
>2nd while loop - writes <TD>'s which vary based on number of carID's selected
>It will loop until all cars have been included
>
>somehow i need to change $carID[1] to $carID[2]
>so I need some help on the best way to do this...
>After i am able to do this I will loop thru until it does not exist, in
>the case of the table above it would be $car_ID[4]
>$next will represent previous number of the array +1
>
>/* start of second while or if/for loop */
>if ($car_ID[$next] != "")
> $table .= "<TD>$car_ID[$next]</TD>";
>
>So basically that is as far as i have got. I would appreciate if anyone
>can provide some direction
>
>Thanks much,
>olinux
>
--
PHP Database 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]