Hello experts,
I have created a dropdown list on each click of drop down another drop down list appears from drop1 database. Below is the code of the same:
dropdown1.php
<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","drop2.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form>
<select name="users" onchange="showUser(this.value)">
<option value="">Select a plan:</option>
<option value="1">Dedicated</option>
<option value="2">VPS</option>
</select>
</form>
<br>
<div id="txtHint"><b>Person info will be listed here.</b></div>
</body>
</html>
drop2.php:
<?php
$q = intval($_GET['q']);
$con = mysqli_connect('localhost','root','','test');
if (!$con)
{
die('Could not connect: ' . mysqli_error($con));
}
mysqli_select_db($con,"ajax_demo");
$sql="SELECT * FROM drop WHERE id = '".$q."'";
$result = mysqli_query($con,$sql);
<tr>
<th>plan1</th>
<th>plan2</th>
</tr>";*/
echo "Plan";
echo "<select>";
while($row = mysqli_fetch_array($result))
{
echo "<option>" . $row['plan1'] . "</option>";
echo "<option>" . $row['plan2'] . "</option>";
}
//echo "</table>";
echo "</select>";
mysqli_close($con);
?>
The above code works perfectly fine for shown the proper dropdown.
Now i want to insert the second dropdown value in another database.
And i am quite stuck in that.