title: Taking Items from an Array and putting them into a database
body: <p>I am still learning so sorry if this is simple... What I am trying to achieve is an online shop checkout system (dont worry it wont be used it is just for my own learning so any sloppy code wont affect a poor business owner but any pickups on sloppy code is always appreciated).</p>
  
  <p>So I have had the customer choose products, these then get stored in arrays and are displyed in the basket. I then want to take the user to a checkout page so they can click 'order' which will then update these items along with their username to an 'Order' table in the database.</p>
  
  <p>I am still getting to grips with arrays (possibly an identifier of what stage of learning I am at) so I am unsure how to take these items (essentially just the ISBN number and Prices) from my basket to a checkout page when I have several different arrays. What I will do is show how I created each array and and how I display it in the basket and hopefully this will be everything you may need! Thank you so much for reading and any help will be greatly appreciated.. I hope this question may help others who are at my stage as well.</p>
  
  <p>Creating the array=</p>
  
  <p><strong>products.php</strong></p>
  
  <pre><code>echo "&lt;a href='addtolist.php?bookname=" . $bookname . "&amp;bookauthor=" . 
       $bookauthor . "&amp;bookpub=" . $bookpub . "&amp;bookprice=" . $bookprice . 
       "&amp;bookisbn=" . $bookisbn . "'&gt;Add to basket&lt;/a&gt;";
  </code></pre>
  
  <p><strong>addtolist.php</strong></p>
  
  <pre><code>&lt;?php
   session_start();
   if ( !isset($_SESSION['username']) )
  {
  header("Location:index.php");
  exit();
  }
  
  $bookarray = array();
  $bookarray['bookname'] = $_GET['bookname'];
  $bookarray['bookauthor'] = $_GET['bookauthor'];
  $bookarray['bookpub'] = $_GET['bookpub'];
  $bookarray['bookisbn'] = $_GET['bookisbn'];
  $bookarray['bookprice'] = $_GET['bookprice'];
  
  $found = false;
  
  if (isset($_SESSION['list']))
  {
    foreach ($_SESSION['list'] as $key =&gt; $another)
    {
      if ($_SESSION['list'][$key]['bookisbn'] == $_GET['bookisbn'])
          {
            $found = true;
            break;
      }
    }
  }
  
  if ($found == false)
  {
    $_SESSION['list'] [] = $bookarray;
  }
  
  header('Location: ' . $_SERVER['HTTP_REFERER']);
  
  exit();
  ?&gt;
  </code></pre>
  
  <p><strong>displaylist.php</strong></p>
  
  <pre><code>&lt;?php
  
  if (!isset($_SESSION['list']))
  {
  echo "No list members selected";
  }
  else
  {
  ?&gt;
  &lt;div id="bket2"&gt;
  
  &lt;table&gt;
  &lt;tr&gt;
  &lt;td class='toprow'&gt;Title&lt;/td&gt;
  &lt;td class='toprow'&gt;Author&lt;/td&gt;
  &lt;td class='toprow'&gt;Publisher&lt;/td&gt;
  &lt;td class='toprow'&gt;ISBN&lt;/td&gt;
  &lt;td class='toprow'&gt;Price&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;?php
  
  $totalprice=0;
  
  foreach ($_SESSION['list'] as $key =&gt; $another)
  {
  ?&gt;
  &lt;tr&gt;
          &lt;td&gt;&lt;?php echo $_SESSION['list'][$key]['bookname']?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $_SESSION['list'][$key]['bookauthor']?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $_SESSION['list'][$key]['bookpub']?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $_SESSION['list'][$key]['bookisbn']?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo "&amp;#163;".$_SESSION['list'][$key]['bookprice']?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href="removefromlist.php?bookisbn= &lt;?php echo $_SESSION['list'][$key]['bookisbn']?&gt; &amp;location= &lt;?php echo
      $_SERVER['PHP_SELF']?&gt; "&gt;[-]&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;?$totalprice += $_SESSION['list'][$key]['bookprice'];?&gt;
      &lt;?php
      }
      }
      ?&gt;
      &lt;/table&gt;
      &lt;div&gt;&lt;h4&gt;Total Price = &amp;#163;&lt;?echo $totalprice;?&gt;&lt;/h4&gt;&lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>Then in my basket div I put </p>
  
  <pre><code>&lt;?php require "displaylist.php" ?
  </code></pre>
  
  <p>Thanks guys</p>