Jump to content

petitesouris

Members
  • Posts

    1
  • Joined

  • Last visited

petitesouris's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Hello I am a real newbie and I tried to use the exemple on the w3schools forum but it does not do what I want so if someone could help me and point me out in the right direction I would be so grateful here is my thing I have a sql database with a schedule I want to be able to build a drop down menue user can select a campus from that sql table and return all the data for that selected campus the most magic option would be for them to be able to do multiple select so they could select the campus AT the moment I am only working with one select option but it really does not work :-) here is the php <!DOCTYPE html> <html> <head> <style> table { width: 100%; border-collapse: collapse; } table, td, th { border: 1px solid black; padding: 5px; } th {text-align: left;} </style> </head> <body> <?php $q = intval($_GET['q']); $con = mysqli_connect('localhost','peter','1234','frozzie_orientation'); if (!$con) { die('Could not connect: ' . mysqli_error($con)); } mysqli_select_db($con,"orientation_schedule"); $sql="SELECT * FROM orientation_schedule WHERE FID = '".$q."'"; $result = mysqli_query($con,$sql); echo "<table> <tr> <th>location</th> <th>title</th> </tr>"; while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['location'] . "</td>"; echo "<td>" . $row['title'] . "</td>"; echo "</tr>"; } echo "</table>"; mysqli_close($con); ?> </body> </html> here is the html <!DOCTYPE html> <html> <head> <script> 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","getuser.php?q="+str,true); xmlhttp.send(); } </script> </head> <body> <form> <select name="orientation_schedule" onchange="showUser(this.value)"> <option value="">Select a campus:</option> <option value="1">Lismore</option> <option value="2">Coffs Harbour</option> <option value="3">Gold Coast</option> </select> </form> <br> <div id="txtHint"><b>Your Campus will be listed here.</b></div> </body> </html> Thank you very much
×
×
  • Create New...