#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2008
    Posts
    8
    Rep Power
    0

    why the outputs are different in the while loop


    PHP Code:
    while($car_result1 = mysqli_fetch_object($car_connect1)){

    <div class="portfolio all" data-cat="all">

    <? echo $car_result1->car_gear?>  // output is stick

    <img alt="Ay <?php if($car_result1->car_gear='auto'){ echo "Auto"; } else { echo "Stick"; };  ?> ">

    <? echo $car_result1->car_gear?> // Output is Auto 

    }
    car_gear field is filled as "stick" in the database. after the image tag, car_gear output changed as "Auto"

    Why the result $car_result1->car_gear; change from "stick" to "Auto" ?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2016
    Location
    Cheshire, UK
    Posts
    77
    Rep Power
    72
    Why don't you post the actual code you are using?

    That code doesn't even parse and thus won't run.
  4. #3
  5. Lord of the Dance
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Oct 2003
    Posts
    4,156
    Rep Power
    2011
    = is used for assignment
    == is used for comparison

IMN logo majestic logo threadwatch logo seochat tools logo