English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

If information would come from a MySQL Database, how do use AJAX to automatically refresh the information on the PHP page (without refreshing the entire page) as the customer interacts with the current information displayed on the page?

I'm using two optionbox, where by changing the first one, the entry of second would change according to our choice in first one! I want to do this without reloading of entire page...

this link (http://www.w3schools.com/ajax/ajax_database.asp) gives an example, but it uses asp, and I'm using php...

please give me the full answer and full code which I have to use, I'm new in Web designing...
Give me the codes which must be in:
1. php file
2. JS file
3. html

2006-07-18 02:46:46 · 5 answers · asked by QuestionAnswer 2 in Computers & Internet Programming & Design

I have to choose a best answer, but non of them is the best!

I got the answer somewhere else, and I'm putting it here:

everything is same as the given link(w3schools.com/...) but instead of asp code, we have to use this php code:

$con = mysql_connect("localhost","Admin","?????????");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test3", $con);
$dd=$_GET['q'];
$ff = "SELECT * FROM CUSTOMERS WHERE CUSTOMERID='".$dd."'";
$result = mysql_query($ff);
if($result)
{

echo "

";
while($row = mysql_fetch_assoc($result))
{
echo "";
echo "";
}
echo "
".$row['name']."".$row['value']."
";
}

?>

2006-07-20 09:26:49 · update #1

5 answers

Are you familiar with PHP? If not I would start there. Otherwise try this.

The biggest part you have to worry about is including your php file here:
var url="getcustomer.asp"

And use this in your php script, using a mysql_connect of course:

$sql="SELECT * FROM table WHERE column ='whatever'";
$res=mysql_query($sql);

echo "

";

while ($row=mysql_fetch_array($res)) {
echo "";
}
echo "
".$row['columnname']."
";

I would strongly recommend reading this website, www.php.net.

2006-07-18 03:50:48 · answer #1 · answered by rob 3 · 0 0

You are asking how to use ajax but you don't seem to know much about what it is.

Ajax is just a fancy term for using the XMLHttpRequest() javascript object. It doesn't matter about your server side scripting language, that can be whatever you want it to be (asp, php, coldfusion)

In the example from w3schools the JS and HTML can stay the same. Just change the asp portion to do the same thing in php.

select from your database
output the results in an HTML table

I found this article helpful when beginning Ajax development.
http://www-128.ibm.com/developerworks/web/library/wa-ajaxintro1.html

2006-07-18 04:11:14 · answer #2 · answered by Anonymous · 0 0

I recommend that you download the Yahoo Ajax API and accompanying documentation.

There you will find all you need to make Ajax (XMLHttpRequest) calls to your back end.

Then all you will need to do is create the form with the onchange settings on the optionboxes and also create another page that will generate the content for the option box you want to change.

If you don't know the basics of programming in PHP go to http://www.php.net/ It is fairly well documented.

If you feel this is beyond your capabilities, look into hiring a free lance programmer, creating a full ajax/php interface takes time.

2006-07-18 04:17:04 · answer #3 · answered by John J 6 · 0 0

Take a look at this forms generation and validation class. http://www.phpclasses.org/formsgeneration

It comes with a plug-in to link 2 or more select inputs like you want. Here is an example page to demonstrate it: http://www.phpclasses.org/browse/file/9879.html

This plug-in can link select inputs with options defined from static arrays or retrieve the options dynamically from MySQL like you want or any other database. Take a look at the example script test_mysql_linked_select.php .

The good thing about these components is that you do not need to learn any Javascript and you can customize the output with your HTML templates.

2006-07-18 08:18:20 · answer #4 · answered by Manuel Lemos 3 · 0 0

in case you elect to very own abode page, Mysql with the AJAX blend you may study the XMLHTTP merchandise. This merchandise makes the silent requests to the server and does all the activity in the website. relax is DHTML trick to refresh the website with out loading it back.

2016-10-08 01:25:14 · answer #5 · answered by esannason 4 · 0 0

fedest.com, questions and answers