I'm trying to make two fields work together and failing so hard.

Discussion in 'PHP' started by Spilgrim, Aug 2, 2014.

  1. #1
    So this is probably going to be a total novice question but I have two fields in particular I am trying to get to work in synergy when an absolute numerical value of zero or "0" is defined for $price to update another field $pricecustom to display "Call for Price".

    This is on a template and I need to automate this rule because I would have to spend hours daily updating vehicles that do not show a price (because it hasn't been updated or the field shows 0 in the XML files I receive daily)

    This is all I have so far:
    
    <?php if($pricecustom) { ?>
    
        <?php echo "E-mail for Price"; ?>
    
    <?php } else { ?>
    
    <?php echo $before . $price . $after ?> <?php if($v) { echo $v; } ?> <?php if (get_option('wp_site') == 'Real Estate') { ?><?php if ($bor == "Rent") { echo stripslashes(get_option('wp_permonthtext'));} ?>
        <?php } ?>
    <?php } ?>
    
    Code (markup):
    [​IMG]
     
    Solved! View solution.
    Last edited: Aug 2, 2014
    Spilgrim, Aug 2, 2014 IP
  2. #2
    Try this

    <?php if($pricecustom || intval($price) == 0) {
        echo "E-mail for Price";
    } 
    else {
       echo $before . $price . $after;
      if($v) { echo $v; }  
    if (get_option('wp_site') == 'Real Estate') { 
     if ($bor == "Rent") { 
          echo stripslashes(get_option('wp_permonthtext'));
          } 
         } 
     } ?>
    PHP:
    and you don't need to hop in and out of php if you aren't doing anything when you get there.
     
    sarahk, Aug 2, 2014 IP
  3. Spilgrim

    Spilgrim Greenhorn

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #3
    You are amazing! Thank you!
     
    Last edited: Aug 2, 2014
    Spilgrim, Aug 2, 2014 IP
  4. sarahk

    sarahk iTamer Staff

    Messages:
    28,897
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #4
    so edit the if statement to see if pricecustom is 0 instead of price
     
    sarahk, Aug 2, 2014 IP
  5. Spilgrim

    Spilgrim Greenhorn

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #5
    I responded to the original post prior to the edited one you put up. That worked perfectly! You are awesome!
     
    Spilgrim, Aug 2, 2014 IP
  6. sarahk

    sarahk iTamer Staff

    Messages:
    28,897
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #6
    oh good, my ipad was making editing difficult on the original post so I had to edit it after saving.
     
    sarahk, Aug 2, 2014 IP
  7. Spilgrim

    Spilgrim Greenhorn

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #7
    You have made my introduction to this forum an amazing one!
     
    Spilgrim, Aug 2, 2014 IP