How to add an PHP IF statement in this Script? -


$sql = "select * item"; $stmt = $conn->prepare($sql); $stmt->execute(); while ($row = $stmt->fetch(pdo::fetch_assoc)) { $data['result_2'] .= '     <div class="col-sm-4 col-md-4">         <div class="content-boxes style-two top-column clearfix animated flipiny" style="opacity: 1;">             <div class="content-boxes-text">                 <form action="php/additem.php" method="post" class="form-inline pull-right">                     <h4>'.$row['itemname'].'</h4><input type="hidden" name="itemname" value="'.$row['itemname'].'">                     <img src="../wholesale/img/sourdough.jpg" class="img-reponsive">                     <p>'.$row['description'].'</p><input type="hidden" name="description" value="'.$row['description'].'">                     <div class="form-group">                     <label class="sr-only" for="exampleinputamount">qty</label>                     <div class="input-group">                     <input type="number" name="qty" class="form-control" id="exampleinputamount" placeholder="how many?">                     </div>                     </div>                     <button type="submit" class="btn btn-primary">add</button>                 </form>             </div>             <!-- //.content-boxes-text -->         </div>         <!-- //.content-boxes -->     </div> '; } 

i want able add if statement in result_2 string. displaying product, , display price depending on users session value? eg.

if ($_session['customer_x'] == a) {     display price } else if ($_session['customer_x'] == b) {     display price b } 

is correct method able add if statement json query?

after starting while loop, put if else there,

$price =""; if ($__session['customer_x'] == a) {    $price='display price a'; } else if ($_session['customer_x'] == b) {   $price='display price b'; } 

and echo price ever want in html

this more neet , less messy way


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -