Re: comparison table script

From: Date: Fri, 23 Mar 2001 01:33:06 +0000
Subject: Re: comparison table script
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-7709@lists.php.net to get a copy of this message
As you can only navigate record by record through the database table I think the only way, as far as I know, is to store the record values into array variables and print it to the page after you'd reached the last record. HTH Jayme. -----Mensagem Original----- De: olinux <olnx@yahoo.com> Para: <PHPLearners@yahoogroups.com>; PHP-DB <php-db@lists.php.net> Enviada em: sexta-feira, 23 de março de 2001 00:52 Assunto: [PHP-DB] comparison table script 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

« previous php.db (#7709) next »