HELP with displaying mysql properly

From: Date: Tue, 19 Dec 2000 04:38:50 +0000
Subject: HELP with displaying mysql properly
Groups: php.general 
Request: Send a blank email to php-general+get-30989@lists.php.net to get a copy of this message
Hi, I am really really new to PHP programming, but I feel i have made some good progress working with my mysql. Basically what i have is a database that using PHP returns selected fields. One of the fields is a path to an image. However I need to figure out a way that if the image is not there it loads by default an image call 1.gif. My code so far is... <?php $db = mysql_connect("localhost", $user, $pass)OR DIE("Unable to connect to database"); ; mysql_select_db("togega",$db) OR DIE("Unable to connect to database"); ; $result = mysql_query("SELECT * FROM cars ",$db); echo "<table border=1 align=center width=80%>\n"; echo "<tr> <td bgcolor=silver><b><font face=arial size=2 color=#000000>No.</font></b></td> <td bgcolor=silver><b><font face=arial size=2 color=#000000>Photo</font></b></td> <td bgcolor=silver><b><font face=arial size=2 color=#000000>Year</font></b></td> <td bgcolor=silver><b><font face=arial size=2 color=#000000>Make</font></b></td> <td bgcolor=silver><b><font face=arial size=2 color=#000000>Model</font></b></td> <td bgcolor=silver><b><font face=arial size=2 color=#000000>CC</font></b></td> <td bgcolor=silver><b><font face=arial size=2 color=#000000>KMS</font></b></td> <td bgcolor=silver><b><font face=arial size=2 color=#000000>Price</font></b></td> </tr>\n"; while ($myrow = mysql_fetch_row($result)) { printf("<tr> <td><font face=arial size=2 color=#FFFFFF>%s</font></td> <td width=130><img src=si/%s.gif></td> <td><font face=arial size=2 color=#FFFFFF>%s</font></td> <td><font face=arial size=2 color=#FFFFFF>%s</font></td> <td><font face=arial size=2 color=#FFFFFF>%s</font></td> <td><font face=arial size=2 color=#FFFFFF>%s</font></td> <td><font face=arial size=2 color=#FFFFFF>%s</font></td> <td><font face=arial size=2 color=#FFFFFF>$%s</font></td> </tr>\n", $myrow[0], $myrow[0], $myrow[1], $myrow[2], $myrow[3], $myrow[4], $myrow[6], $myrow[9], $myrow[10]); } echo "</table>\n"; ?> The stock number & photo are always the same ie Vehicle stock number 3096 and image file 3096.gif But if it is not there we usually subtitute it for 1.gif This is because the vehicle has been unavailable for us to take the photo. Please help. Regards, Dr Nick I'm not really a dr, i just like the Simpsons

« previous php.general (#30989) next »