Passing array from ajax/jquery to php

Passing array from ajax/jquery to php

So I'm making a "wiper blade application guide." I've got a form that starts out talking to my mysql database and grabs all of the makes. The user chooses a make. This calls a function that takes the value of the make and shoots it over to my database and returns all of the models of that make and populates the model dropdown box. Then they choose a model which does the same thing as the last one except it returns years. What is different is that my database has a startYear row and an endYear row which I am sticking together with a '-'. Then the user chooses a year which has to send make, model, and year (or at least model and year) over to the database query. I've managed to get it to send all of the values via an array but I can't figure out how to get them back on the php side. Thanks for reading my story. Here is the code I've got.

index.php
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. <link href="template.css" rel="stylesheet" type="text/css" />
  7. <script language="javascript" type="text/javascript" src="jquery-1.4.2.min.js"></script>
  8. <script type="text/javascript">
  9. function get_models() {
  10.   var make = $("#make").val();
  11.   $.ajax({ url: "getModels.php", global: false, type: "GET", async: false, dataType: "html", data: "make="+make,
  12. success: function (response) {
  13.           var dynamic_options = $("*").index( $('.dynamic')[0] );
  14.           if ( dynamic_options != (-1)) $(".dynamic").remove();
  15.           $("#model").append(response);
  16.           $(".first").attr({selected: ' selected'});
  17.       }
  18.   });
  19.   return false
  20. }
  21. function get_years() {
  22.   var model = $("#model").val();
  23.   $.ajax({
  24.     url: "getYears.php",
  25. global: false,
  26. dataType: "html",
  27. data: "model="+model,
  28. success: function (response)
  29. {
  30.     var dynamic_options_y = $("*").index( $('.dynamic_y')[0] );
  31.  if ( dynamic_options_y != (-1)) $(".dynamic_y").remove();
  32.  $("#year").append(response);
  33.  $(".first_y").attr({selected: ' selected'});
  34.   }
  35.   });
  36.   return false
  37. }
  38. function get_blades() {
  39. var make = $("#make").val();
  40. var model = $("#model").val();
  41. var year = $("#year").val();
  42. var getThem = new Array(make,model,year);
  43. $.ajax({
  44. url:"getBlades.php",
  45. global: false,
  46. dataType: "html",
  47. data: "getThem="+getThem,
  48. success: function (response)
  49. {
  50. //var dynamic_options_b = $("*").index( $('.dynamic_b')[0] );
  51. //if ( dynamic_options_b != (-1)) $(".dynamic_b").remove();
  52. $("#results").append(response);
  53. }
  54. });
  55. }
  56. </script>
  57. </head>
  58. <body>

  59. <?php
  60.   require ("dbconnect_valv.php");
  61. ?>
  62. <div id="wiper-bg">
  63.   <div id="wiperbody">
  64.     <h1>Wiper Blade Application Guide</h1>
  65.     <h2>Choose the make, model and year of your vehicle and we'll tell you which blades and which sizes will best suit your needs.</h2>
  66.     <div id="wipercontents">
  67.       <div id="wipersearch">
  68.         <form name="appGuide" action="#">
  69.           <div id="wipermake" class="inputs">
  70.             <label>Make</label>
  71.             <br />
  72.             <select name="make" id="make" onchange="get_models()">
  73.               <option value="-1">Select Make</option>
  74.               <?php
  75.                 $makeQuery = "select distinct make from blade";
  76.                 $result=mysql_query($makeQuery);
  77.                 while ($row = mysql_fetch_array($result)) { 
  78.                   $id=$row["make"];
  79.                   print "<option value=$id>$id\n";
  80.                 }
  81.                 mysql_close();
  82.               ?>
  83.             </select>
  84.           </div>
  85.           <div id="wipermodel" class="inputs">
  86.             <label>Model</label>
  87.             <br />
  88.             <select name="model" id="model" onchange="get_years()">
  89.               <option value="-1">Select Model</option>
  90.             </select>
  91.           </div>
  92.           <div id="wiperyear" class="inputs">
  93.             <label>Year</label>
  94.             <br />
  95.             <select name="year" id="year" onchange="get_blades()">
  96.               <option value="-1">Select Year</option>
  97.             </select>
  98.           </div>
  99.         </form>
  100.         <div class="clear"></div>
  101.       </div>
  102.       <div id="results">
  103.    
  104.   </div>
  105. </div>
  106. </body>
  107. </html>
getBlades.php
  1. <?php
  2. require ("dbconnect_valv.php");
  3. $make = mysql_real_escape_string($_GET['getThem[0]']);
  4. $model = mysql_real_escape_string($_GET['getThem[1]']);
  5. $year = mysql_real_escape_string($_GET['getThem[2]']);
  6. $startAndEndYears = explode("-", $year);

  7. $result = mysql_query("SELECT blade, clip, drive, pass, rear FROM blade WHERE model='$model' AND make='$make' AND startYear='$startAndEndYears[0]' AND endYear='$startAndEndYears[1]' ") or die(mysql_error());
  8. $row = mysql_fetch_row($result);
  9. echo '<p class="dynamic_b">' . ' ' . $make . $row['blade'] . ' ' . $row['clip'] . ' ' . $row['drive'] . ' ' . $row['pass'] . ' ' . $row['rear'] . '</p>';
  10. for($i=0; $i<=1; $i++) {
  11. echo $startAndEndYears[$i];
  12. }
  13. mysql_close();
  14. ?>
Thanks in advance.

Oh, and here is a link to see it in action.
valvoline.empyreus.com/test/index.php