june_c21 Posted January 21, 2008 Share Posted January 21, 2008 the error is when i click on any list in the pull down menu there is no data come out. what's wrong? <td><select name="tool_list" onChange="showUser(this.value)"> <?php $host = 'localhost'; $user = 'root'; $password = 'admin'; $dbase = 'tool'; $dblink = mysql_connect($host,$user,$password); mysql_select_db($dbase,$dblink); $query = "SELECT title,capacity from tool_list "; $result = mysql_query($query); while($myrow = mysql_fetch_row($result)) { echo "<OPTION VALUE=\"" . $myrow[0] . "\">" . $myrow[0]; } ?> </select></td> var xmlHttp; function showUser(str) { xmlHttp = (window.ActiveXObject)? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="getuser.php" url=url+"?id="+str url=url+"&sid="+Math.random() xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true) xmlHttp.send(null) }function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("txtHint").innerHTML=xmlHttp.responseText } }function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { //Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } <?php $id=$_GET["id"]; $host = 'localhost'; $user = 'root'; $password = 'admin'; $dbase = 'tool'; $dblink = mysql_connect($host,$user,$password); mysql_select_db($dbase,$dblink); $sql="SELECT * FROM tool_list WHERE id = '".$id."'"; $result = mysql_query($sql); echo "<table border='1'> <tr> <th>ID</th> <th>Title</th> <th>Model</th> <th>Capacity</th> <th>Quantity</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row[0] . "</td>"; echo "<td>" . $row[1] . "</td>"; echo "<td>" . $row[2] . "</td>"; echo "<td>" . $row[3] . "</td>"; echo "<td>" . $row[4] . "</td>"; echo "</tr>"; } echo "</table>"; ?> Link to comment https://forums.phpfreaks.com/topic/87016-solved-php-and-ajax-problem/ Share on other sites More sharing options...
pdkv2 Posted January 21, 2008 Share Posted January 21, 2008 make the correction echo "<OPTION VALUE=\"" . $myrow[0] . "\">" . $myrow[0]; TO echo "<OPTION VALUE=\"" . $myrow[0] . "\">" . $myrow[0]."</OPTION>"; Link to comment https://forums.phpfreaks.com/topic/87016-solved-php-and-ajax-problem/#findComment-444962 Share on other sites More sharing options...
june_c21 Posted January 21, 2008 Author Share Posted January 21, 2008 still no data been display out. Link to comment https://forums.phpfreaks.com/topic/87016-solved-php-and-ajax-problem/#findComment-444964 Share on other sites More sharing options...
pdkv2 Posted January 21, 2008 Share Posted January 21, 2008 Have you make your first HTML file to php ? Link to comment https://forums.phpfreaks.com/topic/87016-solved-php-and-ajax-problem/#findComment-444968 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.