Jump to content

mrhussein

Members
  • Posts

    4
  • Joined

  • Last visited

mrhussein's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. thank u i found it and this is the correction : <?php while($data=mysql_fetch_array($query)){ ?><option value="<?php echo $data['id'] ?>"><?php echo $data['name'] ?></option><?php } ?>
  2. actully i changed the extntion to .php and did the following but the page dont want to apear: <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","data.php?q="+str,true);xmlhttp.send();}</script></head><body><form><?php $con = mysql_connect('localhost', 'wordpressuser461', 'r_uw7x.-EJh&');if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("wordpress461", $con);$query=mysql_query("select id from marks"); ?><select name="users" onchange="showUser(this.value)"><option value="">Select a person:</option><?php while($data=mysql_fetch_array($query)){<option value="<?php echo $data['id'] ?>"><?php echo $data['name'] ?></option><?php } ?></select></form><br /><div id="txtHint"><b>Person info will be listed here.</b></div></body></html> it looks there is some error in the code
  3. Thank You Very Very Much your helpfull
  4. Hello, regarding to this example in your website: this example display data from mysql database\table with parameter (dropdown list),and i do input the choices to this list,what if i want same this but the choices in the (dropdown list) come from database\table as well ? anyone can help me plz? this example containing two files as the following: 1. HTML File: <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","getuser.php?q="+str,true);xmlhttp.send();}</script></head><body><form><select name="users" onchange="showUser(this.value)"><option value="">Select a person:</option><option value="1">Peter Griffin</option><option value="2">Lois Griffin</option><option value="3">Glenn Quagmire</option><option value="4">Joseph Swanson</option></select></form><br /><div id="txtHint"><b>Person info will be listed here.</b></div></body></html> 2. PHP File: <?php$q=$_GET["q"];$con = mysql_connect('localhost', 'peter', 'abc123');if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("ajax_demo", $con);$sql="SELECT * FROM user WHERE id = '".$q."'";$result = mysql_query($sql);echo "<table border='1'><tr><th>Firstname</th><th>Lastname</th><th>Age</th><th>Hometown</th><th>Job</th></tr>";while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['FirstName'] . "</td>"; echo "<td>" . $row['LastName'] . "</td>"; echo "<td>" . $row['Age'] . "</td>"; echo "<td>" . $row['Hometown'] . "</td>"; echo "<td>" . $row['Job'] . "</td>"; echo "</tr>"; }echo "</table>";mysql_close($con);?> Thank you very much... Regards,
×
×
  • Create New...