...

View Full Version : Having problem with IF ELSE statement



Bengal313
09-29-2004, 08:44 PM
I am trying to create the condition that will execute the following.
I have a database that has a field "sold". The values in it are either "yes" or "no". So according to that I want the following code to execute.

If the the "sold" field is "no"

<A HREF="sales_detail.php?id=<?php echo $rsforsale->Fields('id'); ?>"><IMG SRC="houses/sales/<?php echo $rsforsale->Fields('folder'); ?>/t.jpg" WIDTH="135" HEIGHT="100" BORDER="0" ALIGN="LEFT"></A>

If the the "sold" field is "yes"


<A HREF="sales_detail.php?id=<?php echo $rsforsale->Fields('id'); ?>"><IMG SRC="houses/sold image/t.jpg" WIDTH="135" HEIGHT="100" BORDER="0" ALIGN="LEFT"></A>


I kinda got it started:

<?php
if ($rsforsale->Fields('sold') == no)
{
<A HREF="sales_detail.php?id=<?php echo $rsforsale->Fields('id'); ?>"><IMG SRC="houses/sold image/t.jpg" WIDTH="135" HEIGHT="100" BORDER="0" ALIGN="LEFT"></A>
}

else
{
<A HREF="sales_detail.php?id=<?php echo $rsforsale->Fields('id'); ?>"><IMG SRC="houses/sold image/t.jpg" WIDTH="135" HEIGHT="100" BORDER="0" ALIGN="LEFT"></A>

}

?>













Basically I want the house image to show if the house house isn't sold and have a generic image that says sold to show when the value in sold field is "yes".

Nightfire
09-29-2004, 09:05 PM
<?php
if ($rsforsale->Fields('sold') == no){
echo '<A HREF="sales_detail.php?id=' .$rsforsale->Fields('id'). '"><IMG SRC="houses/sales/'. $rsforsale->Fields('folder') .'/t.jpg" WIDTH="135" HEIGHT="100" BORDER="0" ALIGN="LEFT"></A>';
}else{
echo '<A HREF="sales_detail.php?id='. $rsforsale->Fields('id') .'"><IMG SRC="houses/sold image/t.jpg" WIDTH="135" HEIGHT="100" BORDER="0" ALIGN="LEFT"></A>';
}
?>

Bengal313
09-30-2004, 01:59 AM
Sorry, made a mistake.

If sold equal to "no" then it should do this.


<A HREF="sales_detail.php?id=<?php echo $rsforsale->Fields('id'); ?>"><IMG SRC="houses/sales/<?php echo $rsforsale->Fields('folder'); ?>/t.jpg" WIDTH="135" HEIGHT="100" BORDER="0" ALIGN="LEFT"></A>





and when it is not "no" it should do this.




<A HREF="sales_detail.php?id='. $rsforsale->Fields('id') .'"><IMG SRC="houses/sold image/t.jpg" WIDTH="135" HEIGHT="100" BORDER="0" ALIGN="LEFT"></A>



On the previous post I have it doing the same thing for both condition....ooppps.

Nightfire
09-30-2004, 02:47 AM
Changed the code above, should work for you now

Bengal313
09-30-2004, 07:44 PM
Great. You are a life saver. Home I can return the favor someday.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum