This example is useful to those programmers who want to use ajax in php.
Tested on
Browse Name: Opera / 8.53
Browse Name: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.2)
Gecko/20060308 Firefox/1.5.0.2
Browse Name: Microsoft Internet Explorer / 6.0
Browse Name : Mozilla 1.5
GetCustomerData.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Get Customer Data</title>
<?php
//create the SQL query string
$sQuery = "Select * from Customers where CustomerId=".$sID;
//make the database connection
$oLink = mysql_connect($sDBServer,$sDBUsername,$sDBPassword);
@mysql_select_db($sDBName) or $sInfo = "Unable to open database";
Antonio Ciccarone wrote :1764
Good job here, this actually worked without a hitch. It's
going to be fun to rip it apart and use it for my own
development. Thanks for sharing!
Marvin Ochieng wrote :1809
hi..thank you for your very good tutorial, it got me to do
something i never managed before, quite pleased with
mylself...however, i have a minor problem...my form
queries the db and returns radio buttons according to the
user's choice a select list above..when i submit the whole
form, the values of the radio buttons drawn from the
XMLHttpRequest..here's a snippet from the php file that's
called by the XMLHttpRequest.
ninanano ninanano wrote :1815
thanks for your codes. really appreciate it. just want to
ask, i try to enter character such as M0001 into the text
field and begin searching, but the script wont do it.
where should i change to make sure character+number such
as M00001 can be accepted? please help, really in need!!
Muhammad Shafique wrote :1860
Hi!
Your Code Example is Good . Run very well in Firfox and IE.
But Problem is that in IE6 . this script run first time
successfully but when any changes in table. this script not execute with changes. this run as first time load.
If any record insert this script will not get that record
in IE. But get value in Firfox successfully.
please can you help that how this problem can solve.
with thanks
Suraj Thapaliya wrote :1861
Thanks all of you.
To make it work in IE 6 put this code in your php file at top
header("Cache-Control: no-cache");
Suraj Thapaliya wrote :1862
One more thing this code is little old So you can find my AJAX code at
http://www.weberdev.com/get_example-4611.html
which gives u the easy way to do the bunch of things
Muhammad Shafique wrote :1863
HI Suraj Thapaliya
According to your sugestion i add no cache in header.
now this is working good in IE6.
thanks
Chris Green wrote :1867
Can you tell me how to do the same thing, but with a dropdown list that you select a name from and shows address, phone and other things below?
Emmanuel Constant wrote :1874
How would you setup the code for Oracle database?