MySQL PHP AJAX Query [1/3]

Type: Code
Level: Intermediate   
Date: 2008-Aug-03
Visited: 2125 times
Rating:
Author: Ivory Morhuld

We will continue with our AJAX Tutorials and make small AJAX Application using AJAX PHP MySQL Query to edit data in MySQL Database.

Lets say we have some MySQL table with employs and we have to list their names in drop-down <select> menu and when we select someone from the list, personal data will be displayed in table where we can edit the data.

First we have to make HTML page where the drop-down list will be generated from MySQL Database by PHP server side and also we have to place some <div></div> tags where will display employs data.

Lets give name 'index.php' for this file.

<html>
<head>
</head>
<body>
<select>
    <option>Select employ</option>
    <?php
    mysql_connect
('localhost','user','pass');
    
mysql_select_db('employ');
    
$query="select id, name from employ order by name asc";
    
$result=mysql_query($query);
    while(list(
$id$name)=mysql_fetch_row($result)) {
        echo 
"<option value=\"".$id."\">".$name."</option>";
    }
    
?>
</select>
<div></div>
</body>
</html>
- MySQL PHP AJAX Query [1/3] -

Need a specific tutorial? Do not hesitate and submit a request!
Related Tags: php mysql query in query ajax  mysql ajax query  mysql query ajax  mysql query with ajax  ajax mysql query  ajax mysql query  ajax php mysql query  ajax query mysql  ajax query mysql  ajax mysql query