AJAX Tutorial and PHP problems

I’ve been following this tutorial:

http://en.w3schools.com/php/php_ajax_database.asp

I’m just trying to get my head around how all the elements of AJAX work together. I have moderate knowledge of PHP, HTML, Javascript etc but I modified the tutorial slightly and now its not behaving as I exepected. (I got the tutorial working initially so I know everything is set up right.)

I wanted to display the full MySQL database above the search dropdown and result. So I added some PHP to do this into the orginal HTML file and then changed the extension to PHP. Now the getUser.php doesn’t seem to be called.

All other files from the tutorial have remained unchanged but here is my modified code from the file I changed from HTML to PHP:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="file:///Macintosh HD/Users/hof/Desktop/Job Sheet/selectuser.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>

<?php
$db_host = 'localhost';
$db_user = '*****';
$db_pwd = '******';

$database = '********';
$table = jobs

if (!mysql_connect($db_host, $db_user, $db_pwd))
    die("Can't connect to database");

if (!mysql_select_db($database))
    die("Can't select database");

// sending query
$result = mysql_query("SELECT * FROM {$table}");
if (!$result) {
    die("Query to show fields from table failed");
}

$fields_num = mysql_num_fields($result);
echo "<div id= 'wholetable'>";
echo "<h1>Table: {$table}</h1>";
echo "<table border='1'><tr>";
// printing table headers
for($i=0; $i<$fields_num; $i++)
{
    $field = mysql_fetch_field($result);
    echo "<td>{$field->name}</td>";
}
echo "</tr>
";
// printing table rows
while($row = mysql_fetch_row($result))
{
    echo "<tr>";

    // $row is array... foreach( .. ) puts every element
    // of $row to $cell variable
    foreach($row as $cell)
        echo "<td>$cell</td>";

    echo "</tr>
";
}
mysql_free_result($result);
echo "</div>";

?>



<form>
Select a User:
<select name="users" onchange="showUser(this.value)">
<option value="1">Peter Griffin</option>
<option value="2">Lois Griffin</option>
<option value="3">Glenn Quagmire</option>
<option value="4">Joseph Swanson</option>
</select>
</form>
<br />
<div id="txtHint"><b>Person info will be listed here.</b></div>



</body>
</html>

What is the problem with doing this? Is it calling PHP via Javascript from within another PHP file?

What is the way I should be doing this - I looked into calling external PHP files from within HTML but that doesn’t seem to be a common solution?