mysql - Ajax and php to create table -
i have following html code in 1 file:
<html> <head> <script> function showuser(str) { if (str == "") { document.getelementbyid("txthint").innerhtml = ""; return; } else { if (window.xmlhttprequest) { // code ie7+, firefox, chrome, opera, safari xmlhttp = new xmlhttprequest(); } else { // code 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","createtable.php?q="+str,true); xmlhttp.send(); } } </script> </head> <body> <form> <select name="users" onchange="showuser(this.value)"> <option value="">select person:</option> <option value="1">equipment 1</option> <option value="2">equipment 2</option> <option value="3">equipment 3</option> <option value="4">equipment 4</option> </select> </form> <div id="txthint"><b>person info listed here...</b></div> </body> </html>
my createtable.php code:
<?php $q = intval($_get['q']); $con = mysqli_connect('localhost','root','','results'); if (!$con) { die('could not connect: ' . mysqli_error($con)); } mysqli_select_db($con,"results"); $sql="create table '".$q."'"; $result = mysqli_query($con,$sql); mysqli_close($con); ?>
when chose equipment one, table named 1 not being created. think wrong near create table part in createtable.php. how can fix this?
Comments
Post a Comment