-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
75 lines (50 loc) · 1.8 KB
/
Copy pathindex.php
File metadata and controls
75 lines (50 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB">
<head>
<title>Inspired Evolution : : AJAX Example</title>
<link rel="stylesheet" type="text/css" href="Form.css" media="screen" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$('select[name="category_id"]').change(function(){
var id = $('select[name="category_id"] option:selected').val();
$.ajax({
url: 'Query.php?category_id=' + id,
success: function(response){
$('#DataDisplay').html(response);
}
});
});
});
</script>
</head>
<body>
<h1 id="Tutoring">Inspired-Evolution.com : : AJAX Example</h1>
<p>Below is an application example which utilizes the following web technologies to display the data. HTML, CSS, PHP/MySQL, JQuery and AJAX.</p>
<?php
#connect to MySQL
$conn = mysql_connect( "localhost","username","pw")
or die( "You did not successfully connect to the DB!" );
#select the specified database
$db = mysql_SELECT_DB ("DBName", $conn )
or die ( "Error connecting to the database test!");
?>
<form name="sports" id="sports">
<legend>Select a Sport</legend>
<select name="category_id">
<option value="">--Select a Sport--</option>
<?php
$sql = "SELECT category_id, sport FROM sports ".
"ORDER BY sport";
$db = mysql_query($sql);
while($row = mysql_fetch_array($db))
{
echo "<option value=\"".$row['category_id']."\">".$row['sport']."</option>\n ";
}
?>
</select>
</form>
<br />
<div id="DataDisplay"></div>
</body>
</html>