Forum Moderators: open
I am making an AJAX application with the following flow,
1 - when starts it will do php pagination and will fetch the first record from the MySQL DB.
Each Record consists of One Country Name and five cities name underneath it. One Radio button in front of every City Name that vistor can choose to see information about that city. e.g
Destination: Country Name
radio: City1
radio: City2
radio: City3
radio: City4
<<pre Show Information next>>
2 - when someone selects a city and press Show Information button it will fetch information related to this city from the DB and will display under the above block using AJAX without loading page.
3 - when he press next it will fetch the record for the next Country and will show the same using AJAX.
4 - Prev will take visitor to his previous choice and will also show the results for the city he had selected.
now what I want to ask is that how can I send query to DB and fetch the results as array or different variables,
on next link i use this function,
var url = "ReadCountry.php?id="; // The server-side script
function requestNext() {
var sId = document.getElementById("txtqId").value;
//document.write (url + sId)
http.open("GET", url + escape(sId), true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
}
and fetch results using this function,
function handleHttpResponse() {
if (http.readyState == 4) {
if(http.status==200) {
var results=http.responseText;
var results2=http.responseText;
document.getElementById('divCountry').innerHTML = results;
}
}
}
$sQuery = "Select * from mcq where qid=".$_GET['id'];
this query is executing successfully and so far I don't have any problem BUT I want to read the different columns values related to the country id and to return an array of this information to my HTML page so that on HTML page I can use these values to show radio buttons and questions etc.
like on this line
document.getElementById('divCountry').innerHTML = results;
i dont want to assign complete output to divCountry but i want to use it as an array so that i can have full control on all values.
Can anybody help please that how can i return array fetched from DB using the query back to the HTML page to use in my HTML page to create radio buttons.
In fact on each radio button i will store CityID and when someone will select city and will press Show Information button I will again call the PHP page and will fetch information based on the id of city. Also I will store the information in session array so that when someone clicks Previous link he can see what he had selected.
thanks in advance.
PS: Try using Sajax....makes life much easier