Page 1 of 1

If statement i think

Posted: Wed Jul 02, 2003 5:09 am
by jamrop
Hey i am trying to show a picture that is the name of a id key for a car. The thing i am trying to work out, is that is there is not a picture, how what i put a message saying 'awaiting picture'

code

Code: Select all

<?php
<?php $sql = 'SELECT * FROM cars ' ; 


						$rs=mysql_query($sql,$db);
							while ($r = mysql_fetch_array($rs))
								{
									$carid=$r["carid"];
									$make=$r["make"];
									$engine=$r["engine"];
									$year=$r["year"];
									$des=$r["des"];
									$mot=$r["mot"];
									$price=$r["engine"];
									  ?>
                            <tr> 
                              <td bgcolor="#99CCFF"> <strong><font size="-1" face="Verdana, Arial, Helvetica, sans-serif"> 
                                <?php echo $make ?></strong></td>
                            </tr>
                            <tr> 
                              <td><img src = "uploaded/<?php echo $carid?>.jpg"></td>


?>

Many thanks

Posted: Wed Jul 02, 2003 5:43 am
by []InTeR[]

Code: Select all

if(!file_exists("uploaded/".$carid.".jpg")){
  echo "awaiting picture";
}

Posted: Wed Jul 02, 2003 6:07 am
by jamrop
hey thanks

i have been trying this so the x picture does not show, but it does not seem to be working

Code: Select all

<?php
 if(!file_exists("uploaded/".$carid.".jpg")){?>
<img src = "uploaded/<?php echo $carid; ?>.jpg">
<?php } else { 
  echo "awaiting picture"; 
} 
?>
any ideas?

many thanks

Posted: Wed Jul 02, 2003 6:09 am
by []InTeR[]

Code: Select all

<?php
 if(!file_exists("uploaded/".$carid.".jpg")){
  echo "awaiting picture"; 
} else {
?>
<img src = "uploaded/<?php echo $carid; ?>.jpg">
<?  
} 
?>
The ! before the file_exist meens, not..
So the statement is 'if file not exists do say `awaiting picture` else show image'

Posted: Wed Jul 02, 2003 6:14 am
by jamrop
ah i c

thanks