title: In PHP and MySQL, how to view multiple order information in the other page
body: <p>I've learned a lot from <a href="https://stackoverflow.com/questions/25825183/mysqli-and-php-sends-only-single-products-on-the-database">this question</a>, on how to send multiple order information on the database. In my table rows of "order.php" is composed of rows about order information sent by the customers. My code is only for single order only. But I want to view in the other page the multiple orders sent by one customer.</p>
  
  <p>Here is my code for "order.php"</p>
  
  <pre><code>&lt;?php
  session_start();
  $conn = mysqli_connect('localhost','root','','sampsix');
  if(mysqli_connect_errno()){
      echo 'Failed to connect: '.mysqli_connect_error();
  }
  
  if(isset($_POST['delete'])){
      $DeleteQuery = "DELETE FROM orders WHERE id='$_POST[hidden]'";
      mysqli_query($conn,$DeleteQuery);
  }
  if(isset($_POST['view'])){
      header('Location: view_order.php');
  }
  
  $query = "SELECT * FROM orders ORDER BY id";
  $results = mysqli_query($conn,$query);
  
  echo '&lt;table border="1"&gt;';
      echo '&lt;tr&gt;';
          echo '&lt;th&gt;ID&lt;/th&gt;';
          echo '&lt;th&gt;Firstame&lt;/th&gt;';
          echo '&lt;th&gt;Lastname&lt;/th&gt;';
          echo '&lt;th&gt;Email&lt;/th&gt;';
          echo '&lt;th&gt;Order Name&lt;/th&gt;';
          echo '&lt;th&gt;Order Code&lt;/th&gt;';
          echo '&lt;th&gt;Order Qty&lt;/th&gt;';
          echo '&lt;th&gt;Sub Total&lt;/th&gt;';
      echo '&lt;/tr&gt;';
  
      while($orderData = mysqli_fetch_array($results)){
     echo '&lt;form action="order.php" method="POST"&gt;';
      echo '&lt;tr&gt;';
          echo '&lt;td&gt;'.$orderData['id'].'&lt;/td&gt;';
          echo '&lt;td&gt;'.$orderData['firstname'].'&lt;/td&gt;';
          echo '&lt;td&gt;'.$orderData['lastname'].'&lt;/td&gt;';
          echo '&lt;td&gt;'.$orderData['email'].'&lt;/td&gt;';
          echo '&lt;td&gt;'.$orderData['ordername'].'&lt;/td&gt;';
          echo '&lt;td&gt;'.$orderData['ordercode'].'&lt;/td&gt;';
          echo '&lt;td&gt;'.$orderData['orderqty'].'&lt;/td&gt;';
          echo '&lt;td&gt;'.$orderData['subtotal'].'&lt;/td&gt;';
  
         echo '&lt;td&gt;&lt;input type="hidden" name="hidden" value="'.$orderData['id'].'"&gt;&lt;/td&gt;';
          echo '&lt;td&gt;&lt;input type="submit" name="delete" value="Delete"&gt;&lt;/td&gt;';
      echo '&lt;/form&gt;';
          echo "&lt;td&gt;&lt;a href='view_order.php?id=".$orderData['id']."'&gt;View&lt;/a&gt;&lt;/td&gt;";
      echo '&lt;/tr&gt;';
  
  }
  echo '&lt;/table&gt;';
  mysqli_close($conn);
  ?&gt;
  </code></pre>
  
  <p>And here is my "view_order.php" where in the order information is in there:</p>
  
  <pre><code>&lt;?php
  include_once('config.php');
  
  if(isset($_GET['id'])){
      $id = $_GET['id'];
  
  $query = $mysqli-&gt;query("SELECT id,firstname,lastname,email,ordername,ordercode,orderqty,subtotal  FROM orders WHERE id='$id'");
  
  if($query){
          while($obj = $query-&gt;fetch_object()){
             echo 'ID: '.$obj-&gt;id;
             echo 'Firstname: '.$obj-&gt;firstname;
             echo 'Lastname: '.$obj-&gt;lastname;
             echo 'Email: '.$obj-&gt;email;
             echo 'Order Name: '.$obj-&gt;ordername;
             echo 'Order Code: '.$obj-&gt;ordercode;
             echo 'Order Qty: '.$obj-&gt;orderqty;
             echo 'Sub total: '.$obj-&gt;subtotal;
          }
     }
  }
  
  ?&gt;
  </code></pre>
  
  <p>This code above also execute single order only. I just thinking what if the customers has multiple order and I want to view it all in the other page.</p>