Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder Bengal313's Avatar
    Join Date
    Jun 2002
    Location
    Metro Detroit
    Posts
    298
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Having problem with IF ELSE statement

    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".
    "Knowledge Speaks But Wisdom Listens"

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    PHP Code:
    <?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>';
    }
    ?>
    Last edited by Nightfire; 09-30-2004 at 02:47 AM.

  • #3
    Regular Coder Bengal313's Avatar
    Join Date
    Jun 2002
    Location
    Metro Detroit
    Posts
    298
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Sorry, made a mistake.

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

    PHP Code:
    <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.



    PHP Code:
    <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.
    Last edited by Bengal313; 09-30-2004 at 02:04 AM.
    "Knowledge Speaks But Wisdom Listens"

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Changed the code above, should work for you now

  • #5
    Regular Coder Bengal313's Avatar
    Join Date
    Jun 2002
    Location
    Metro Detroit
    Posts
    298
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Great. You are a life saver. Home I can return the favor someday.
    "Knowledge Speaks But Wisdom Listens"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •