Re: It works but HUH!

From: Date: Wed, 20 Dec 2000 02:52:08 +0000
Subject: Re: It works but HUH!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-31130@lists.php.net to get a copy of this message
I saw a few issues so will comment on them . Also note the more orderly syntax. Use whitespace, it is your friend. : <? while ($myrow = mysql_fetch_row($result)) { echo "<tr><td>$myrow[0]</td><td width=130>"; // You have /si/image.gif here if (file_exists("/si/$myrow[0].gif")) { // And si/image.gif here, which are different paths. The above // path is most likely incorrect so it will never exist, which // is the cause of your issue. echo "<img src=\"si/$myrow[0].gif\">"; } else { // This uses si/1.gif path and since works this is now doubt // the proper path. echo "<img src=\"si/1.gif\"></td>"; echo "<td>$myrow[1]</td><td>$myrow[2]</td><td>$myrow[3]</td>"; echo "<td>$myrow[4]</td><td>$myrow[6]</td>"; // Typo here, remove a '$' echo "<td>$$myrow[9]</td></tr>\n"; // This is an orphan, does it belong? $myrow[0]; echo "</table>\n"; } } ?> Also, consider reading up on strings, check out this useful tutorial : http://www.zend.com/zend/tut/using-strings.php It will be of use. Pay special note to the use of ' and " and concatenates. And remember, whitespace very good! :-) Regards, Philip --.sig [ Want to write Good code? First, write Bad code. ] [ Will work for Money : http://www.cornado.com/ ] On Wed, 20 Dec 2000, Sefton wrote: > Hello Everybody, > > This sort of works. > A. It returns all the values > B. it only writes the first row into a table the rest is all over the place > C. The images that are there still just load the 1.gif image. > > What could I be doing wrong? > Yes I am a dumb ass and cannot work it out, even with this part coming from > a question i have already asked. > Please HELP! > > It is supposed to return the information from a MySql Database. If the photo > of the vehicle is there then it is display in the first cell of that row, > but if the photo is not there it displays the 1.gif image. > <? > // My first lot of code goes here, I haven't displayed it. It is the problem > > while ($myrow = mysql_fetch_row($result)) { > > echo "<tr><td>$myrow[0]</td><td width=130>"; > if (file_exists("/si/$myrow[0].gif")) { > echo "<img src=\"si/$myrow[0].gif\">"; > } > else { > echo "<img src=\"si/1.gif\"></td>"; > > echo > "<td>$myrow[1]</td><td>$myrow[2]</td><td>$myrow[3]</td>"; > echo > "<td>$myrow[4]</td><td>$myrow[6]</td><td>$$myrow[9]</td></tr>\n"; > $myrow[0]; > echo "</table>\n"; > } > } > ?> > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#31130) next »