You are here: Re: [PHP] Mixed Up Values « PHP « IT news, forums, messages
Re: [PHP] Mixed Up Values

Posted by Matt Harnaga on 10/02/43 11:14

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.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация