NathanS Posted November 16, 2007 Share Posted November 16, 2007 Hi guys, I've just created an ajax form whereby if you select one option from a dropdown list, it'll populate the next one dependent on the choice. However, I have used an array for this so far, but I need to read from a MySQL database - anyone give any clues as to the best way of doing this? I've included my code below. Thanks in advance!! Array (dataPage.php) <?php $dataOptions = array(); $dataOptions["Ford"] = array("Choose One", "Fiesta", "Focus", "Escort", "KA"); $dataOptions["Renault"] = array("Choose One", "Scenic", "Clio", "Espace", "Megane"); $dataOptions["Fiesta"] = array("Choose One", "GTI", "Blah", "BlahExec"); if(isset($_POST["dataRequest"]) && isset($dataOptions[$_POST["dataRequest"]])) { foreach($dataOptions[$_POST["dataRequest"]] as $secondaryOptions) { printf("%s,", $secondaryOptions); }} ?> dynamicForm AJAX function clearField(obj) { if (obj.defaultValue==obj.value) obj.value = ''; } function chooseVehicle(requestedData,objectID) { fetchData('dataPage.php',requestedData,objectID); } function filterData(pageRequest,objectID){ if (pageRequest.readyState == 4 && (pageRequest.status==200 || window.location.href.indexOf("http")==-1)) { var object = document.getElementById(objectID); object.options.length = 0; if(pageRequest.responseText != '') { var arrSecondaryData = pageRequest.responseText.split(','); for(i = 0; i < arrSecondaryData.length; i++) { if(arrSecondaryData[i] != '') object.options[object.options.length] = new Option(arrSecondaryData[i], arrSecondaryData[i]); }}}} Link to comment https://forums.phpfreaks.com/topic/77605-converting-an-array-to-read-from-a-mysql-database/ Share on other sites More sharing options...
rajivgonsalves Posted November 16, 2007 Share Posted November 16, 2007 read from the mysql database or write it too a mysql database ? if its read what is your database fieldname etc. more information is required Link to comment https://forums.phpfreaks.com/topic/77605-converting-an-array-to-read-from-a-mysql-database/#findComment-392809 Share on other sites More sharing options...
NathanS Posted November 16, 2007 Author Share Posted November 16, 2007 Read from, instead of reading from the array I need it to read from a table called system_list_vehicle. The database fields are: ABIMAKE, ABIMODEL, ABIMARK Thanks! Link to comment https://forums.phpfreaks.com/topic/77605-converting-an-array-to-read-from-a-mysql-database/#findComment-392812 Share on other sites More sharing options...
NathanS Posted November 16, 2007 Author Share Posted November 16, 2007 It also has 40,000 rows. ??? Link to comment https://forums.phpfreaks.com/topic/77605-converting-an-array-to-read-from-a-mysql-database/#findComment-392995 Share on other sites More sharing options...
rajivgonsalves Posted November 16, 2007 Share Posted November 16, 2007 40,000 rows getting it into anything into html will hang your browser choose some criteria you wanna select them on otherwise your just gonna hang the browser Link to comment https://forums.phpfreaks.com/topic/77605-converting-an-array-to-read-from-a-mysql-database/#findComment-393005 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.