Hi Folks,
I have a site which allows me to enter data and the form works well
What I would like to do is the following:
I have a select box which already has the names of events loaded into it.
I have the data in MySQL
I have seen an example at this link which is similar to what I would like to do except that the table will have to have enough rows to populate the same information that was provided in the first link.
My challenge again is that I can see the twq codes need to be linked somehow and do not know how to go about this.
I have created two files and each cvan be veiwed at the following links:
Select Box
The table
The select box seems to veiw ok but when selction is made nothing happens.
If I try veiw the table then the page views blank. When I select a tournament name then there is activity as the text that is there is over written by the blank page. It is just that the table is not appearing as intended.
It would be great if you could advise.
The two files are posted below:
SELECT BOX
THE TABLE PAGE
I have a site which allows me to enter data and the form works well
What I would like to do is the following:
I have a select box which already has the names of events loaded into it.
I have the data in MySQL
I have seen an example at this link which is similar to what I would like to do except that the table will have to have enough rows to populate the same information that was provided in the first link.
My challenge again is that I can see the twq codes need to be linked somehow and do not know how to go about this.
I have created two files and each cvan be veiwed at the following links:
Select Box
The table
The select box seems to veiw ok but when selction is made nothing happens.
If I try veiw the table then the page views blank. When I select a tournament name then there is activity as the text that is there is over written by the blank page. It is just that the table is not appearing as intended.
It would be great if you could advise.
The two files are posted below:
SELECT BOX
PHP Code:
<html>
<head>
<script type="text/javascript">
function showUser(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","MySQLreturntable.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form>
<select name="users" onchange="showUser(this.value)">
<option value="">Select a tournament:</option>
<option value="1">Kempton Park Golf Club</option>
<option value="2">Kyalami Golf Club</option>
<option value="3">St.Francis Links</option>
<option value="4">Gardener Ross Golf Estate</option>
<option value="5">Rustenburg Golf Club</option>
<option value="6">Witbank Golf Course</option>
<option value="7">Ebotse Golf Estate</option>
<option value="8">Umhlali Golf Estate</option>
<option value="9">Durban Country Club</option>
<option value="10">Steenburg Golf Club</option>
<option value="11">Maccauvlei Golf Club</option>
<option value="12">Mt.Edgecombe Country Club</option>
<option value="13">Randpark Golf Club</option>
<option value="14">Oubaai Golf Club</option>
<option value="15">Zwartkop Country Club</option>
<option value="16">ERPM Golf Club</option>
<option value="17">Polokwane Golf Club</option>
<option value="18">Erivale</option>
<option value="19">Royal Cape Golf Club</option>
<option value="20">Paarl Golf Club</option>
<option value="21">Irene Country Club</option>
<option value="22">Stellenbosch Golf Club</option>
<option value="23">Mowbray Golf Club</option>
<option value="24">Bryanston Golf Club</option>
<option value="25">Schoeman Park Golf Club</option>
<option value="26">Nelspruit Golf Club</option>
<option value="27">The Hill</option>
<option value="28">Mossel Bay Golf Club</option>
<option value="29">Wanderers Golf Club</option>
<option value="30">Pecanwood Golf Club</option>
</select>
</form>
<br />
<div id="txtHint"><b>The Results of the Winners will be listed here.</b></div>
</body>
</html>
PHP Code:
<?php
$q=$_GET["q"];
$con = mysql_connect("localhost", "*****_r*****h", "********") or
if (!$con)
{
die ("Hey loser, check your server connection.");
}
mysql_select_db("eghfya_Members", $con);
$sql="SELECT * FROM _Form_Nr_6 WHERE id = '".$q."'";
$result = mysql_query($sql);
echo "<table border='1'>
<tr>
<th>NAME</th>
<th>SURNAME</th>
<th>DIVISION</th>
<th>SCORE</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['champions_name'] . "</td>";
echo "<td>" . $row['champion_surname'] . "</td>";
echo "<td>" . $row['champion_of _the_day_comes_from:'] . "</td>";
echo "<td>" . $row['champions_gross_score'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
Comment