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 <[EMAIL PROTECTED]>
Para: <[EMAIL PROTECTED]>; PHP-DB <[EMAIL PROTECTED]>
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






-- 
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]

Reply via email to