Re: HELP with displaying mysql properly

From: Date: Tue, 19 Dec 2000 22:54:56 +0000
Subject: Re: HELP with displaying mysql properly
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-31088@lists.php.net to get a copy of this message
if (!file_exists($whatever . ".gif")){ $whatever = '1'; } ----- Original Message ----- From: "Sefton" <c.sefton@xtra.co.nz> Newsgroups: php.general Sent: Monday, December 18, 2000 10:38 PM Subject: [PHP] HELP with displaying mysql properly > 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 > > > > -- > 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 (#31088) next »