title: create a Compare page using checkbox and data from mysql
body: <p>Im a newbie in PHP and I want to create a simple webpage app for my website, I was able to produce this page base on a tutorial here. </p>
  
  <pre><code>&lt;?php
    $con = mysql_connect("localhost","*****","*****");
    if (!$con)
    {
     die('Could not connect: ' . mysql_error());
    }
  
  mysql_select_db("*****", $con);
  
  $result = mysql_query("SELECT * FROM products");
  
  echo "&lt;table border='1'&gt;
  &lt;tr&gt;
  &lt;th&gt;Name&lt;/th&gt;
  &lt;th&gt;classification&lt;/th&gt;
  &lt;/tr&gt;";
  
  while($row = mysql_fetch_array($result))
    {
  
  
    echo "&lt;tr&gt;";
    echo "&lt;td&gt;" . $row['name'] . "&lt;/td&gt;";
    echo "&lt;td&gt;" . $row['classification'] . "&lt;/td&gt;";
    echo "&lt;td&gt;&lt;input type='checkbox' name='{number[]}' value='{$row['prodID']}' /&gt;&lt;/td&gt;";
  
    echo "&lt;/tr&gt;";
    }
  echo "&lt;/table&gt;";
  
  mysql_close($con);
  
  
  ?&gt;
  
  &lt;?php
  
  
  
  ?&gt;
  
  &lt;html&gt;
  &lt;head&gt;
  
  &lt;/head&gt;
  &lt;form name="form1" method="post" action="result_page.php"&gt; 
  
  &lt;input type="submit"  name="Submit"      value="Submit"&gt; 
  &lt;/p&gt; 
  &lt;/form&gt; 
  
  &lt;body&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>but my problem is how to create a result_page.php to show the selected entries or data base on the selected checkbox so i can create a comparison page. I have this as being my result_page.php but nothing is showing up. I know Im doing something wrong but I cant find out.</p>
  
  <pre><code>&lt;?php
  error_reporting(E_ALL);
  
  $host = 'localhost';                
  $user = '******';       
  $pass = '******';       
  $dbname = '******';         
  $connection = mysql_connect($host,$user,$pass) or die (mysql_errno().":  ".mysql_error()."&lt;BR&gt;"); 
  mysql_select_db($dbname);
  
  $sql = "SELECT * FROM products WHERE prodID IN ("; 
  
  foreach ($_POST['number'] as $product) $sql .= "'" . $product . "',";
  
  
  
  $sql = substr($sql,0,-1) . ")"; 
  
  
  
  $result = mysql_query($sql); 
  
  while ($myrow = mysql_fetch_array($result))
  
  
  { 
  echo "&lt;table border=1&gt;\n";
  
  echo "&lt;tr&gt;&lt;td&gt;Name&lt;/td&gt;&lt;td&gt;Position&lt;/td&gt;&lt;/tr&gt;\n";
  
  do {
  
  printf("&lt;tr&gt;&lt;td&gt;%s %s&lt;/td&gt;&lt;td&gt;%s&lt;/tr&gt;\n", $myrow["1"], $myrow["2"], $myrow["3"]);
  
  } while ($myrow = mysql_fetch_array($result));
  
   echo "&lt;/table&gt;\n";
  
  } 
  
  ?&gt;
  </code></pre>