jeudi 27 avril 2017

Running multiple if statements at once PHP

I'm trying to print the quantity chosen from a table to another page. I have a series of if statements for this to show if a quantity has been inputted and if it has then it will display the quantity and the item.

The problem is that it is only running the first if statement and ignoring the rest of them. If anyone knows how I could run them all it would be a great help!

<?php

  if(!empty($_POST['qtybang']))
  {
    echo $qtybang.' Bang Bang Chicken<br>';
  }

  if(!empty($_POST['$qtyFlatbread']))
  {
    echo $qtyFlatbread.' Flatbread<br>';
  }

  if(!empty($_POST['$qtyMexican']))
  {
  echo $qtyMexican.' Mexican Bean Stew<br>';
  }

  if(!empty($_POST['$qtyrice']))
  {
  echo $qtyrice.' Rice Bowl<br>';
  }

  if(!empty($_POST['$qtySandwiche']))
  {
  echo $qtySandwiche.' sandwiches<br>';
  }


  if(!empty($_POST['$qtyCapachino']))
  {
  echo $qtyCapachino.' Capachino<br>';
  }


  if(!empty($_POST['$qtyAmericano']))
  {      
  echo $qtyAmericano.' Americano<br>';
  }


  if(!empty($_POST['$qtyExpresso']))
  {
  echo $qtyExpresso.' Expresso<br>';
  }?>

Order Table

Output

Aucun commentaire:

Enregistrer un commentaire