Jump to content


If Statments In mysql and PHP


2 replies to this topic

#1 Crofty

    Young Padawan

  • Members
  • Pip
  • 32 posts

Posted 23 September 2006 - 07:10 AM

Ok well im trying to use a if statments to display different outputs, but it wont display out of stock when quantity = 0

while($row = mysql_fetch_assoc($result)){
	if ($row['quantity'] = "0"){
		echo' 
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
	<td>
	<table width="100%" height="101" border="0" align="center" valign="top">
	  <tr valign="middle">
	 	<td align="center"><img align="center" height="140" width="100" src="'.$row['picurl'].'"></td>
		<td width="300" height="97"><a href="index.php?view=dvd&id='.$row['dvdid'].'">'.$row['dvdname'].'</a></td>
		<td width="100" align="center">&pound;'.$row['price'].'</td>
		<td width="100" align="center">Out Of Stock!</td>
	  </tr>
	</table>
	</td>
  </tr>
</table>';
}else{
	echo' 
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
	<td>
	<table width="100%" height="101" border="0" align="center" valign="top">
	  <tr valign="middle">
	 	<td align="center"><img align="center" height="140" width="100" src="'.$row['picurl'].'"></td>
		<td width="300" height="97"><a href="index.php?view=dvd&id='.$row['dvdid'].'">'.$row['dvdname'].'</a></td>
		<td width="100" align="center">&pound;'.$row['price'].'</td>
		<td width="100" align="center"> '.$row['quantity'].'</td>
	  </tr>
	</table>
	</td>
  </tr>
</table>';
}
}


#2 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 23 September 2006 - 07:17 AM

Simple one,

if ($row['quantity'] == "0"){

:)

#3 Crofty

    Young Padawan

  • Members
  • Pip
  • 32 posts

Posted 23 September 2006 - 07:26 AM

oh yeah i forgot about the double =

thanks





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users