title: sql query only reads the first number of the ID
body: <p>Hi I have created a website that allows you to download videos you can specify what videos you want using drop down boxes. there are five drop down boxes subject section and principle and then seperatley there are job role and career. the selection boxes are connected to each other for example if you select english in the subject box it only shows the sections connected to english subject and the same with principle it will only show the principles related to the section. my problem at the moment is when choose the job role and careers which values should be (1, 15) actually return the results (1,1) which says there are no results related to them. my full sql query code is: </p>
  
  <p>`</p>
  
  <pre><code>&lt;?php
  class SelectList
  {
      protected $conn;
  
          public function __construct()
          {
              $this-&gt;DbConnect();
          }
  
          protected function DbConnect()
          {
              include "db_config.php";
              $this-&gt;conn = mysql_connect($host,$user,$password) OR die("Unable to connect to the database");
              mysql_select_db($db,$this-&gt;conn) OR die("can not select the database $db");
              return TRUE;
          }
  
          public function ShowCategory()
          {
              $sql = "SELECT subject_id,description FROM subject";
              $res = mysql_query($sql,$this-&gt;conn);
              $category = '&lt;option value="%"&gt;Subject&lt;/option&gt;';
              while($row = mysql_fetch_array($res))
              {
                  $category .= '&lt;option value="' . $row['subject_id'] . '"&gt;' . $row['description'] . '&lt;/option&gt;';
              }
              return $category;
          }
  
          public function ShowType()
          {
              $sql = "SELECT section_id,description FROM section WHERE subject_id=$_POST[id]";
              $res = mysql_query($sql,$this-&gt;conn);
              $type = '&lt;option value="%"&gt;choose...&lt;/option&gt;';
              while($row = mysql_fetch_array($res))
              {
                  $type .= '&lt;option value="' . $row['section_id'] . '"&gt;' . $row['description'] . '&lt;/option&gt;';
              }
              return $type;
          }
  
           public function ShowPrinciple()
          {
              $sql = "SELECT principle_id,description FROM principle WHERE section_id=$_POST[id]";
              $res = mysql_query($sql,$this-&gt;conn);
              $principle = '&lt;option value="%"&gt;choose...&lt;/option&gt;';
              while($row = mysql_fetch_array($res))
              {
                  $principle .= '&lt;option value="' . $row['principle_id'] . '"&gt;' . $row['description'] . '&lt;/option&gt;';
              }
              return $principle;
          }
  
          public function GetResults()
          { 
          $vars = $_POST["comboboxselections"]; // this gets comboboxselections from index.php
  
  
             $box = ""; // placeholder for the html results to be returned to 
             $sql = "SELECT title,blurb FROM media WHERE subject_id = $vars[0] AND section_id= $vars[1] AND principle_id= $vars[2] "; // sql query 
             $box = $sql;
  
             $hasprintedrecords = false; // capture records if there are no records printed to screen 
             //$box .= $sql;
              $res = mysql_query($sql,$this-&gt;conn); // connection to database and also getting the results from query
              while($row = mysql_fetch_array($res)) // the loop while there are results within the array run the function
              {
                  $hasprintedrecords = true;// if there are records this equals true if not equals false 
                  $box .= '&lt;div style=";height:120px;"id=\"Video\"&gt;&lt;br/&gt;&lt;div style="border-style:solid;border-width:1px;border-color:#00000;width:504px;float:right;"id=\"Title\"&gt;'.$row['title'].'&lt;/div&gt; &lt;div style="width:220px;height:100px;float:left;border-style:solid;border-width:1px;border-color:#000000;" id=\"VideoImage\"&gt;hii&lt;/div&gt; &lt;div style="height:50px;width:504px;float:right;padding:2px;margin-bottom:5px;" id=\"Blurb\"&gt;'.$row['blurb'].'&lt;/div&gt;&lt;div style="height:21px;width:152px;background:url(images/bg_top_img2-09.jpg) repeat-x;color:#ffffff;padding-left:2px;float:left;border:1px solid #000000;position:relative;border-radius:15px;text-align:center;" id=\"Downloads\"&gt; Download &lt;/div&gt;&lt;/div&gt;'; // if results are available then display to screen 
              }
              if ( $hasprintedrecords == false) // if there are no results then function below is run  
              { 
              $box .='&lt;div id=\"video\" style=\" border-style:solid; border-color:#000000; border-width:1px;\"&gt; &lt;div style="border-style:dashed; border-color:#f90;" id="text"&gt; no media found for this selection.&lt;/div&gt;&lt;/div&gt;'; // returns html message to screen 
              }
              return $box; // returns results to the screen
          }
  
          public function ShowJobRole() { 
  
          $sql = "SELECT jobrole_id,description FROM jobrole";
              $res = mysql_query($sql,$this-&gt;conn);
              $jobrole = '&lt;option value="%"&gt;Job role&lt;/option&gt;';
              while($row = mysql_fetch_array($res))
              {
                  $jobrole .= '&lt;option value="' . $row['jobrole_id'] . '"&gt;' . $row['description'] . '&lt;/option&gt;';
              }
              return $jobrole;
          } 
  
  
          public function ShowCareer() { 
  
  
          $sql = "SELECT career_id,description FROM career WHERE jobrole_id=$_POST[id]";
              $res = mysql_query($sql,$this-&gt;conn);
              $career = '&lt;option value="%"&gt;Career&lt;/option&gt;';
              while($row = mysql_fetch_array($res))
              {
                  $career .= '&lt;option value="' . $row['career_id'] . '"&gt;' . $row['description'] . '&lt;/option&gt;';
              }
              return $career;
          } 
  
  
  
          public function get_job () { 
          $vars1 = $_POST["comboboxselections1"]; // this gets comboboxselections from index.php
  
              $res = mysql_query($sql,$this-&gt;conn);
  
  
             $box = ""; // placeholder for the html results to be returned to 
             $sql = "SELECT title,blurb FROM media_career_crossref INNER JOIN media ON media.media_id = media_career_crossref.media_id WHERE media_career_crossref.jobrole_id = $vars1[0] AND media_career_crossref.career_id = $vars1[1] ";
             $box = $sql;
  
             $hasprintedrecords = false; // capture records if there are no records printed to screen 
             //$box = $sql;
              $res = mysql_query($sql,$this-&gt;conn); // connection to database and also getting the results from query
              while($row = mysql_fetch_array($res)) // the loop while there are results within the array run the function
              {
                  $hasprintedrecords = true;// if there are records this equals true if not equals false 
                  $box .= '&lt;div style=";height:120px;"id=\"Video\"&gt;&lt;br/&gt;&lt;div style="border-style:solid;border-width:1px;border-color:#00000;width:504px;float:right;"id=\"Title\"&gt;'.$row['title'].'&lt;/div&gt; &lt;div style="width:220px;height:100px;float:left;border-style:solid;border-width:1px;border-color:#000000;" id=\"VideoImage\"&gt;hii&lt;/div&gt; &lt;div style="height:50px;width:504px;float:right;padding:2px;margin-bottom:5px;" id=\"Blurb\"&gt;'.$row['blurb'].'&lt;/div&gt;&lt;div style="height:21px;width:152px;background:url(images/bg_top_img2-09.jpg) repeat-x;color:#ffffff;padding-left:2px;float:left;border:1px solid #000000;position:relative;border-radius:15px;text-align:center;" id=\"Downloads\"&gt; Download &lt;/div&gt;&lt;/div&gt;'; // if results are available then display to screen 
              }
              if ( $hasprintedrecords == false) // if there are no results then function below is run  
              { 
              $box .='&lt;div id=\"video\" style=\" border-style:solid; border-color:#000000; border-width:1px;\"&gt; &lt;div style="border-style:dashed; border-color:#f90;" id="text"&gt; no media found for this selection.&lt;/div&gt;&lt;/div&gt;'; // returns html message to screen 
              }
              return $box; // returns results to the screen
  
  
          } 
          }
  $opt = new SelectList();
  ?&gt;
  </code></pre>
  
  <p>and the javascript and html that are the drop down boxes are: </p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
  
              &lt;!--[if !IE]&gt;&lt;!--&gt;
              &lt;link rel="stylesheet" type="text/css" href="Content.css"&gt;
              &lt;!--&lt;![endif]--&gt;
  
              &lt;!--[if IE 7]&gt;
              &lt;link rel="stylesheet" type="text/css" href="IE7Content.css" /&gt;
              &lt;![endif]--&gt;
          &lt;script src="http://code.jquery.com/jquery-1.10.1.min.js"&gt;&lt;/script&gt;
          &lt;script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"&gt;&lt;/script&gt;
      &lt;/head&gt;
  &lt;script type="text/javascript"&gt;
          $(document).ready(function(){
                  $("select#type").attr("disabled","disabled");
                  $("select#category").change(function(){
                  $("select#type").attr("disabled","disabled");
                  $("select#type").html("&lt;option&gt;wait...&lt;/option&gt;");
                  var id = $("select#category option:selected").attr('value');
                  $.post("select_type.php", {id:id}, function(data){
                  $("select#type").removeAttr("disabled");
                  $("select#type").html(data);
              });
          });
          $("select#principle").attr("disabled","disabled");
                  $("select#type").change(function(){
                  $("select#principle").attr("disabled","disabled");
                  $("select#principle").html("&lt;option&gt;wait...&lt;/option&gt;");
                  var id = $("select#type option:selected").attr('value');
                  $.post("select_principle.php", {id:id}, function(data){
                  $("select#principle").removeAttr("disabled");
                  $("select#principle").html(data);
              });
          });
  
                  $("select#career").attr("disabled","disabled");
                  $("select#jobrole").change(function(){
                  $("select#career").attr("disabled","disabled");
                  $("select#career").html("&lt;option&gt;wait...&lt;/option&gt;");
                  var id = $("select#jobrole option:selected").attr('value');
                  $.post("select_career.php", {id:id}, function(data){
                  $("select#career").removeAttr("disabled");
                  $("select#career").html(data);
              });
          });
  
          $("form#select_form").submit(function()
          {
              var cat = $("select#category option:selected").attr('value');
              var type = $("select#type option:selected").attr('value');
              var princ = $("select#principle option:selected").attr('value');
                  $txt = cat + type + princ;
                  var id = $("select#type option:selected").attr('value');
                  $.post("get_results.php", {comboboxselections:$txt}, function(data){
                  $("#Results").html(''+data);
              });
              if(cat&gt;0 &amp;&amp; type&gt;0 &amp;&amp; princ&gt;0)
              {
              }
              else
              {
                  $("#result").html("you must choose three options!");
              }
              return false;
          });
  
          $("form#select_job").submit(function(){
              var job = $("select#jobrole option:selected").attr('value');
              var car = $("select#career option:selected").attr('value');
                  $txt1 = job + car;
                  var id = $("select#career option:selected").attr('value');
                  $.post("get_jobresults.php", {comboboxselections1:$txt1}, function(data){
                  $("#Results").html(''+data);
              });         
              if(job&gt;0 &amp;&amp; car&gt;0)
              {
              }
              else
              {
                  $("#result").html("you must choose two options!");
              }
              return false;
          });
          });
  &lt;/script&gt;   
  &lt;body&gt;
      &lt;?php
          $host=""; // Host name
          $username=""; // Mysql username
          $password=""; // Mysql password
          $db_name=""; // Database name
          $tbl_name=""; // Table name
  
          session_start();
          $_SESSION["username"];
          $_SESSION["password"];
          $_SESSION["access"];
      ?&gt;
      &lt;div id="Container"&gt;
          &lt;div id="Header"&gt;
              &lt;div id="SignIn"&gt; &lt;!-- This is the SignIn --&gt;
                  &lt;a href="logout.php"&gt;Logout&lt;/a&gt; &lt;!-- This is the Logout button --&gt;
                  &lt;a href="login.php"&gt;Login&lt;/a&gt; &lt;!-- This is the Login button --&gt;
                  &lt;a href="index.php"&gt;Home&lt;/a&gt; &lt;!-- This is the Home button --&gt; 
              &lt;/div&gt;&lt;!-- This is the end of SignIn --&gt;
              &lt;div id="MainNavigation"&gt;
  
                  &lt;a href="content.php"&gt;&lt;img id="button2" src="images/banner2new.jpg"&gt;&lt;/a&gt;&lt;/li&gt;  
                  &lt;a href="contributors.php"&gt;&lt;img id="button1" src="images/banner3new.jpg"&gt;&lt;/a&gt; 
  
  
              &lt;/div&gt;&lt;!-- End of the MainNavigation --&gt;
          &lt;/div&gt; &lt;!-- End of the Header --&gt;
          &lt;div id="Content"&gt;
  
              &lt;?php
              $Public = "Please Login in or register an account to be able to see the content";               
              if($_SESSION["username"] == "")
              {   
                        header("Location: http://thor/classroom/login.php");
              }
  
              if($_SESSION["access"] == "Consumer")
              {
                  echo "&lt;div id=\"Options\"&gt;";
                  include "select.class.php"; 
                  echo "&lt;form id=\"select_form\"&gt;";
                  echo "&lt;div class=\"selecttitle\"&gt;"; 
                  echo "Choose a subject:";
                  echo "&lt;/div&gt;";
                  echo "&lt;select style=\"width:200px; margin-left:10px;\" id=\"category\" name=\"cat\" &gt;";
                  echo $opt-&gt;ShowCategory();
                  echo "&lt;/select&gt;";
                  echo "&lt;br /&gt;";
                  echo "&lt;br /&gt;";
  
                  echo "&lt;div class=\"selecttitle\"&gt;";
                  echo "Choose a section:";
                  echo "&lt;/div&gt;";              
                  echo "&lt;select style=\"width:200px; margin-left:10px;\"id=\"type\"&gt;";
                  echo "&lt;option value=\"%\"&gt;";
                  echo "Section";
                  echo "&lt;/option&gt;";
                  echo "&lt;/select&gt;";
                  echo "&lt;br /&gt;";
                  echo "&lt;br /&gt;";
  
                  echo "&lt;div class=\"selecttitle\"&gt;";
                  echo "Choose a principle:";
                  echo "&lt;/div&gt;";
                  echo "&lt;select style=\"width:200px; margin-left:10px;\"id=\"principle\"&gt;";
                  echo "&lt;option value=\"%\"&gt;";
                  echo "Principle";
                  echo "&lt;/option&gt;";
                  echo "&lt;/select&gt;";
                  echo "&lt;br /&gt;";
                  echo "&lt;br /&gt;";
                  echo "&lt;input style=\"margin-left:10px;\" type=\"submit\" value=\"Search\"/&gt;";
                  echo "&lt;/form&gt;";
  
                  echo " ------ Or ------";
  
  
                  echo "&lt;form id=\"select_job\"&gt;";
                  echo "&lt;div class=\"selecttitle\"&gt;";
  
                  echo "Choose a Job Role:";
                  echo "&lt;/div&gt;";              
                  echo "&lt;select style=\"width:200px; margin-left:10px;\"id=\"jobrole\"&gt;";
                  echo $opt -&gt;ShowJobRole();
                  echo "&lt;/select&gt;";
                  echo "&lt;br /&gt;";
                  echo "&lt;br /&gt;";
  
                  echo "&lt;div class=\"selecttitle\"&gt;";
                  echo "Choose a career:";
                  echo "&lt;/div&gt;";
                  echo "&lt;select style=\"width:200px; margin-left:10px;\"id=\"career\"&gt;";
                  echo "&lt;option value=\"%\"&gt;";
                  echo "career";
                  echo "&lt;/option&gt;";
                  echo "&lt;/select&gt;";
                  echo "&lt;br /&gt;";
                  echo "&lt;br /&gt;";
                  echo "&lt;input style=\"margin-left:10px;\" type=\"submit\" value=\"Search\"/&gt;";
                  echo "&lt;/form&gt;";
                  echo "&lt;/div&gt;"; // end of the options tag any new content that needs to be on left side put inside this tag
                  echo "&lt;div id=\"Results\"&gt;";
                  echo "&lt;/div&gt;"; // end of the results results div needs to be out of the options tag
              }
  
                  if($_SESSION["access"] == "Contributor")
              {
                  echo "&lt;div id=\"Options\"&gt;";
                  include "select.class.php"; 
                  echo "&lt;form id=\"select_form\"&gt;";
                  echo "&lt;div class=\"selecttitle\"&gt;"; 
                  echo "Choose a subject:";
                  echo "&lt;/div&gt;";
                  echo "&lt;select style=\"width:200px; margin-left:10px;\" id=\"category\" name=\"cat\" &gt;";
                  echo $opt-&gt;ShowCategory();
                  echo "&lt;/select&gt;";
                  echo "&lt;br /&gt;";
                  echo "&lt;br /&gt;";
  
                  echo "&lt;div class=\"selecttitle\"&gt;";
                  echo "Choose a section:";
                  echo "&lt;/div&gt;";              
                  echo "&lt;select style=\"width:200px; margin-left:10px;\"id=\"type\"&gt;";
                  echo "&lt;option value=\"%\"&gt;";
                  echo "Section";
                  echo "&lt;/option&gt;";
                  echo "&lt;/select&gt;";
                  echo "&lt;br /&gt;";
                  echo "&lt;br /&gt;";
  
                  echo "&lt;div class=\"selecttitle\"&gt;";
                  echo "Choose a principle:";
                  echo "&lt;/div&gt;";
                  echo "&lt;select style=\"width:200px; margin-left:10px;\"id=\"principle\"&gt;";
                  echo "&lt;option value=\"%\"&gt;";
                  echo "Principle";
                  echo "&lt;/option&gt;";
                  echo "&lt;/select&gt;";
                  echo "&lt;br /&gt;";
                  echo "&lt;br /&gt;";
                  echo "&lt;input style=\"margin-left:10px;\" type=\"submit\" value=\"confirm\"/&gt;";
                  echo "&lt;/form&gt;";
  
                  echo "&lt;form id=\"select_job\"&gt;";
                  echo "&lt;div class=\"selecttitle\"&gt;";
                  echo "Choose a Job Role:";
                  echo "&lt;/div&gt;";              
                  echo "&lt;select style=\"width:200px; margin-left:10px;\"id=\"jobrole\"&gt;";
                  echo $opt -&gt;ShowJobRole();
                  echo "&lt;/select&gt;";
                  echo "&lt;br /&gt;";
                  echo "&lt;br /&gt;";
  
                  echo "&lt;div class=\"selecttitle\"&gt;";
                  echo "Choose a career:";
                  echo "&lt;/div&gt;";
                  echo "&lt;select style=\"width:200px; margin-left:10px;\"id=\"career\"&gt;";
                  echo "&lt;option value=\"%\"&gt;";
                  echo "career";
                  echo "&lt;/option&gt;";
                  echo "&lt;/select&gt;";
                  echo "&lt;br /&gt;";
                  echo "&lt;br /&gt;";
                  echo "&lt;input style=\"margin-left:10px;\" type=\"submit\" value=\"confirm\"/&gt;";
                  echo "&lt;/form&gt;";
                  echo "&lt;/div&gt;"; // end of the otions tag any new content that needs to be on left side put inside this tag
                  echo "&lt;div id=\"Results\"&gt;";
                  echo "&lt;/div&gt;"; // end of the results results div needs to be out of the otions tag
              }
  
                  if($_SESSION["access"] == "Administrator")
              {
                  echo "&lt;div id=\"Options\"&gt;";
                  include "select.class.php"; 
                  echo "&lt;form id=\"select_form\"&gt;";
                  echo "&lt;div class=\"selecttitle\"&gt;"; 
                  echo "Choose a subject:";
                  echo "&lt;/div&gt;";
                  echo "&lt;select style=\"width:200px; margin-left:10px;\" id=\"category\" name=\"cat\" &gt;";
                  echo $opt-&gt;ShowCategory();
                  echo "&lt;/select&gt;";
                  echo "&lt;br /&gt;";
                  echo "&lt;br /&gt;";
  
                  echo "&lt;div class=\"selecttitle\"&gt;";
                  echo "Choose a section:";
                  echo "&lt;/div&gt;";              
                  echo "&lt;select style=\"width:200px; margin-left:10px;\"id=\"type\"&gt;";
                  echo "&lt;option value=\"%\"&gt;";
                  echo "Section";
                  echo "&lt;/option&gt;";
                  echo "&lt;/select&gt;";
                  echo "&lt;br /&gt;";
                  echo "&lt;br /&gt;";
  
                  echo "&lt;div class=\"selecttitle\"&gt;";
                  echo "Choose a principle:";
                  echo "&lt;/div&gt;";
                  echo "&lt;select style=\"width:200px; margin-left:10px;\"id=\"principle\"&gt;";
                  echo "&lt;option value=\"%\"&gt;";
                  echo "Principle";
                  echo "&lt;/option&gt;";
                  echo "&lt;/select&gt;";
                  echo "&lt;br /&gt;";
                  echo "&lt;br /&gt;";
                  echo "&lt;input style=\"margin-left:10px;\" type=\"submit\" value=\"confirm\"/&gt;";
                  echo "&lt;/form&gt;";
  
                  echo "&lt;form id=\"select_job\"&gt;";
                  echo "&lt;div class=\"selecttitle\"&gt;";
                  echo "Choose a Job Role:";
                  echo "&lt;/div&gt;";              
                  echo "&lt;select style=\"width:200px; margin-left:10px;\"id=\"jobrole\"&gt;";
                  echo $opt -&gt;ShowJobRole();
                  echo "&lt;/select&gt;";
                  echo "&lt;br /&gt;";
                  echo "&lt;br /&gt;";
  
                  echo "&lt;div class=\"selecttitle\"&gt;";
                  echo "Choose a career:";
                  echo "&lt;/div&gt;";
                  echo "&lt;select style=\"width:200px; margin-left:10px;\"id=\"career\"&gt;";
                  echo "&lt;option value=\"%\"&gt;";
                  echo "career";
                  echo "&lt;/option&gt;";
                  echo "&lt;/select&gt;";
                  echo "&lt;br /&gt;";
                  echo "&lt;br /&gt;";
                  echo "&lt;input style=\"margin-left:10px;\" type=\"submit\" value=\"confirm\"/&gt;";
                  echo "&lt;/form&gt;";
                  echo "&lt;/div&gt;"; // end of the otions tag any new content that needs to be on left side put inside this tag
                  echo "&lt;div id=\"Results\"&gt;";
                  echo "&lt;/div&gt;"; // end of the results results div needs to be out of the otions tag
              }
              ?&gt;  
          &lt;/div&gt; &lt;!-- End of the Content --&gt;
          &lt;!-- &lt;div id="SignIn"&gt;
                  &lt;a href="logout.php"&gt;Logout&lt;/a&gt;
                  &lt;a href="login.php"&gt;Login&lt;/a&gt;
                  &lt;a href="index.php"&gt;Home&lt;/a&gt;
              &lt;/div&gt; --&gt;
      &lt;/div&gt; &lt;!-- End of the Container --&gt;
  &lt;/body&gt; &lt;!-- End of the Body --&gt;
  &lt;/html&gt; &lt;!-- End of the Html --&gt;`
  </code></pre>