Okay so I've done some modification. Can you tell me why its not loading the show names.
This is my updated php script.
PHP Code:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
try
{
if (window.XMLHttpRequest) // firefox
reqsend = new XMLHttpRequest(); // create object for ff and other browsers
else // IE 5.0+
reqsend = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){};
function getNames(typed)
{
var created = "option";
var i = 0;
try
{
reqsend.open("POST", "getNames.php", true);
var stuff = "type=" + typed;
reqsend.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); // need for POST
reqsend.setRequestHeader("Content-Length", stuff.length);
reqsend.send(stuff); // actual send
reqsend.onreadystatechange = function()
{
if (reqsend.readyState == 4 && reqsend.status == 200)
{
var name = reqsend.responseXML.getElementsByTagName("name");
for(i=0; i<name.length; i++)
{
var opts = document.getElementById('names');
var newopt = document.createElement(created);
opts.appendChild(newopt);
newopt.innerHTML = name[i].childNodes[0].nodeValue;
}
}
};
}
catch(e){};
}
</script>
</head>
<body>
<?php
/* setupshow.php */
/* This form after submission takes the results of the form and makes a new show ready for adding matches. */
require ('database.php');
echo '<form action="setupshow.php" method="post">';
echo '<fieldset>';
echo '<legend>Enter the following information to setup a show:</legend>';
echo '<p>Weekly Show or Pay-Per View:<select name="type"><option value="">Select a Show Type</option>';
$query = 'SELECT type FROM shows';
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)){
echo "<option value=\"{$row['type']}\">{$row['type']}</option>\r";
}
echo '</select></p>';
echo "<select id=\"names\"</select>";
echo '<p>Show Label:<input name="showlabel" type="text" readonly="true" size="5"></p>';
echo '<p>Location:<input name="location" type="text"></p>';
echo '<p>Arena:<input name="arena" type="text"></p>';
echo '<div align="center"><input name="submit" type="submit" value="Submit"><input name="sumbitted" type="hidden" value="TRUE"></div>';
echo '</fieldset>';
echo '</form>';
?>
</body>
</html>
This is the getNames.php script.
PHP Code:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
if(isset($_POST['type']) && !empty($_POST['type']))
{
require ('database.php');
$type = mysql_real_escape_string($_POST['type']);
$sql = "SELECT * FROM shows WHERE type='$type'";
$result = mysql_query($sql);
header("Content-Type: text/xml");
echo "<all>";
while( $data = mysql_fetch_assoc($result))
{
echo $data['showname'];
}
echo "</all>";
mysql_close();
}
?>
</body>
</html>