title: how to use checkbox values to access database using php?
body: <p>Here goes my code which accepts the order through checkboxes and textbox.</p>
  
  <p>place_order.php</p>
  
  <pre><code>&lt;?php require_once("includes/session.php"); ?&gt;
      &lt;?php require_once("includes/connection.php"); ?&gt;
      &lt;?php require_once("includes/functions.php"); ?&gt;
      &lt;?php global $public; 
       confirm_logged_in(); ?&gt;
      &lt;?php include("includes/header.php"); ?&gt;
      &lt;table&gt;
      &lt;tr&gt;
           &lt;td id="navigation"&gt;
              &lt;br&gt;&lt;br&gt;    &lt;a href="index.php"&gt;Return to public site&lt;/a&gt;
          &lt;/td&gt;`enter code here`
      &lt;td id="page"&gt;
      &lt;br&gt;
      &lt;h3&gt;Place Your Order Here...&lt;/h3&gt;&lt;br&gt;
      &lt;?php  
      $menu = get_all_menu($public);
      print "&lt;form method='POST' action='process.php'&gt;";
      while($info = mysql_fetch_array($menu))
      {
  
          echo "&lt;fieldset style='width:830;height:260 padding='15'&gt;";
          echo "&lt;legend&gt;&lt;h4&gt;{$info['menu_name']}&lt;/h4&gt;&lt;/legend&gt;";
          echo "&lt;table cellpadding='6'&gt;&lt;tr&gt;";
          $submenu = get_submenus_for_menu($info['id'],$public);
          while($sub = mysql_fetch_array($submenu)) 
          {
          if($sub['sub_position']==4 || $sub['sub_position']==7 || $sub['sub_position']==10 ||$sub['sub_position']==13 )
          {
              echo "&lt;/tr&gt;&lt;tr&gt;";
          }
          echo "&lt;td&gt;&lt;input type='checkbox' name='feature[]' value='{$sub['submenu_name']}'&gt;". $sub['submenu_name'] ;
          echo "&lt;td&gt;&lt;input type='textbox' name= 'quantity[]' value='Qty' size='4'&gt;";
  
  
          } 
          echo "&lt;/table&gt;";
          print "&lt;/fieldset&gt;";
          echo "&lt;br&gt;&lt;br&gt;";
  
      }
         print "&lt;input type='submit' name='b1' value='        ORDER !!      '&gt;";
  
        //echo "&lt;/tr&gt;&lt;/table&gt;";
        print "&lt;/form&gt;";
  
       ?&gt;
       &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
      &lt;?php require("includes/footer.php"); ?&gt;
  </code></pre>
  
  <p>code for get_cost_for_submenus()</p>
  
  <pre><code>function get_cost_for_submenus($submenu_name, $public = true) {
          global $connection;
          $query = "SELECT * 
                  FROM submenu ";
          $query .= "WHERE submenu_name= {$submenu_name} ";
          //$query .= "LIMIT 1";
          $result_set = mysql_query($query, $connection);
          confirm_query($result_set);
          return $result_set;
      }
  </code></pre>
  
  <p>process.php which calculates the price...</p>
  
  <pre><code>&lt;?php require_once("includes/session.php"); ?&gt;
  &lt;?php require_once("includes/connection.php"); ?&gt;
  &lt;?php require_once("includes/functions.php"); ?&gt;
  &lt;?php confirm_logged_in(); ?&gt;
  &lt;?php include("includes/header.php"); ?&gt;
  
  &lt;table&gt;
  &lt;tr&gt;
       &lt;td id="navigation"&gt;
          &lt;br&gt;&lt;br&gt;    &lt;a href="index.php"&gt;Return to public site&lt;/a&gt;
      &lt;/td&gt;
  &lt;td id="page"&gt;
  &lt;br&gt;
  &lt;?php
      $items = $_POST['feature'];
      $quantity = $_POST['quantity'];
      $price=0;
      $N = count($items);
      $n = count($quantity);
      for($i=0;$i&lt;$N;$i++)    
      {
          $temp_item=get_cost_for_submenus($items['i'],$public);
          $price+=($temp_item['cost']*$quantity['i']);    
      }
      echo "&lt;br&gt;&lt;h3&gt; TOTAL AMOUNT FOR YOUR ORDER = ". $price ."&lt;/h1&gt; ";
  ?&gt;
  &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;              
  &lt;?php require("includes/footer.php"); ?&gt;
  </code></pre>
  
  <p>I'm getting the following errors when executing place_order.php(after login).</p>
  
  <pre><code>Notice: Undefined index: i in G:\xampp\htdocs\choc_room\process.php on line 22
  
  Notice: Undefined variable: public in G:\xampp\htdocs\choc_room\process.php on line 22
  Database query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2
  </code></pre>
  
  <p>please someone help me out.... I'm new to php language </p>