Re: Mixed Up Values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mark Sargent wrote:

Hi All,

with the below code, $myrow[1] should = product_name's value, $myrow[2] should = product_model_number's value and $myrow[3] should = product_serial_number's value, but, product_name's value is not being displayed, and the values are being moved to the left 1. Meaning product_model_number is being displayed as product_name and so forth. What is wrong with the code.? Cheers.

Mark Sargent.

$result = mysql_query("SELECT product_name, product_model_number,
23 product_serial_number FROM Products",$db);
24
25
26
27 echo "<table border=1>\n";
28
29
30
31 echo "<tr><td>Product Name</td><td>Product Model Number</td><td>Product
32 Serial Number</td></tr>\n";
33
34
35
36 while ($myrow = mysql_fetch_row($result)) {
37
38
39
40 printf("<tr><td>%s</td><td>%s</td><td>%s</td></tr>\n",
41 $myrow[1], $myrow[2], $myrow[3]);


Change line 41 to $myrow[0], $myrow[1], $myrow[2]);

By default, arrays start from 0 and work their way up, unless you supply index names/values yourself.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux