tribol Posted July 28, 2010 Share Posted July 28, 2010 The first three fields were already there when i started but I wanted to add a fourth. I got this far but it's breaking on me still. It won't call up the last field. Doens't help that I don't know much about it... <?php // functions function pullQuery($strMethod, $sqlSelect, $sqlDatatable, $sqlWhere, $sqlOrder, $output, $outputFieldOne, $outputFieldTwo, $outputFieldThree, $outputFieldFour) { echo $query="$sqlSelect FROM ".DB_DATABASE.".$sqlDatatable $sqlWhere $sqlOrder"; $result=mysql_query($query); while ($rs=mysql_fetch_object($result)) { if ($outputFieldOne) $newoutput=str_replace("#VALUE1#",$rs->$outputFieldOne,$output); if ($outputFieldTwo) $newoutput=str_replace("#VALUE2#",$rs->$outputFieldTwo,$newoutput); if ($outputFieldThree) $newoutput=str_replace("#VALUE3#",$rs->$outputFieldThree,$newoutput); if ($outputFieldFour) $newoutput=str_replace("#VALUE4#",$rs->$outputFieldFour,$newoutput); if ($strMethod=="echo") echo $newoutput; if ($strMethod=="return") return $newoutput; } mysql_query($query); } // if ($_GET['province']) { echo "<select name=\"consultantcity\" onChange=\"ajaxCall('call-data-shops.php?city='+this.value+'','location');\">"; echo "<option value=\"\" selected=\"selected\">- City -</option>"; pullQuery("echo", "SELECT DISTINCT city", "shopData", "WHERE province='".$_GET['province']."' AND shopType='Retail' AND status='Open'", "ORDER BY city ASC", "<option value=\"#VALUE1#\">#VALUE1#</option>\n", "city", "", ""); echo "</select>"; } if ($_GET['city']) { echo "<select name=\"consultantShop\ onChange=\"ajaxCall('call-data-shops.php?city='+this.value+'','consultant');\">"; echo "<option value=\"\" selected=\"selected\">- Location -</option>"; pullQuery("echo", "SELECT *", "shopData", "WHERE city='".$_GET['city']."' AND shopType='Retail' AND status='Open'", "ORDER BY shopName ASC", "<option value=\"#VALUE1#\">#VALUE1#</option>\n", "shopName", "", ""); echo "</select>"; } if ($_GET['location']) { echo "<select name=\"consultantName\ onChange=\"ajaxCall('call-data-shops.php?city='+this.value+'','consultant');\">"; echo "<option value=\"\" selected=\"selected\">- Consultant -</option>"; pullQuery("echo", "SELECT *", "shopStaffDetails", "WHERE firstName='".$_GET['firstName']."' AND lastName='".$_GET['lastName']."' AND shopName='consultantShop' AND status='Open'", "ORDER BY firstName ASC", "<option value=\"#VALUE1#\">#VALUE1#</option>\n", "consultantName", "", ""); echo "</select>"; } ?> and the section of the form: <table width="100%" border="0"> <tr> <td width="49%" align="right" valign="top"><span class="red">*</span> Please select the location that is the most convenient for you: </td> <td width="51%" valign="top"><div style="float:left"> <select name="province" id="province" onChange="ajaxCall('call-data-shops.php?province='+this.value+'','consultantcity')"> <option value="" selected="selected">- Province -</option> <option value="Alberta">Alberta</option> <option value="British Columbia">British Columbia</option> <option value="Nova Scotia">Nova Scotia</option> <option value="Ontario">Ontario</option> </select> <div id="consultantcity" style="padding:5px 0 5px 0"> <select name="consultantcity"> <option value="" selected="selected" disabled="disabled">- City -</option> </select> </div> <div id="location" style="padding:5px 0 5px 0"> <select name="consultantShop" id="consultantShop"> <option value="" selected="selected" disabled="disabled">- Location -</option> </select> </div> <div id="consultant" style="padding:5px 0 5px 0"> <select name="consultantName" id="consultantName"> <option value="" selected="selected" disabled="disabled">- Consultant -</option> </select> </div> </div></td> </tr> <tr> <td> </td> <td> </td> </tr> </table> Any help would be greatly appreciated. Cheers Quote Link to comment https://forums.phpfreaks.com/topic/209142-ajax-wont-populate-fourth-field/ Share on other sites More sharing options...
chipowski Posted July 30, 2010 Share Posted July 30, 2010 Hi. Do you mean Ontario is the 4th field you've added? Quote Link to comment https://forums.phpfreaks.com/topic/209142-ajax-wont-populate-fourth-field/#findComment-1093222 Share on other sites More sharing options...
Zane Posted July 30, 2010 Share Posted July 30, 2010 When you say "it's breaking on you", what do you mean? Also, this echo $query="$sqlSelect FROM will cause a bad query error. Unless, the value of $sql is "Explain ". Quote Link to comment https://forums.phpfreaks.com/topic/209142-ajax-wont-populate-fourth-field/#findComment-1093238 Share on other sites More sharing options...
tribol Posted July 30, 2010 Author Share Posted July 30, 2010 I figured it out, i had the call for the fourth field all wrong... no, it wasn't ontario. Quote Link to comment https://forums.phpfreaks.com/topic/209142-ajax-wont-populate-fourth-field/#findComment-1093240 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.