troubleshooting Question

How to create dropdown automatically

Avatar of magento
magento asked on
JavaScriptPHPAJAX
11 Comments1 Solution247 ViewsLast Modified:
Hi,

I have created a table and displaying the contents via php code.

--
-- Table structure for table `personal`
--

CREATE TABLE IF NOT EXISTS `personal` (
  `id` int(11) NOT NULL,
  `name` char(20) NOT NULL,
  `contact` bigint(20) NOT NULL,
  `address` varchar(40) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

<html>
<head>
<style>
body
{
background-color:#d0e4fe;
}
h1
{
color:black;
text-align:center;
}
p
{
font-family:"Times New Roman";
font-size:20px;
}
</style>
</head>
<body>




<center>
<table width="50%" border="1" cellspacing="0" cellpadding="0">
 <tr>
 		    <td width="30%"><h2><center><b>Name</b></center></h2></td>
 		    <td width="30%"><h2><center><b>Contact</b></center></h2></td>
 		    <td width="40%"><h2><center><b>Address</b></center></h2></td>
</tr>
<?php
    include('config.php');
    $sql="SELECT * FROM personal ";
    $query = mysql_query($sql);
    $numrows=mysql_numrows($query);
 $row=0;

		  while($row<$numrows)
 {

 $name=mysql_result($query,$row,"name");
 $contact=mysql_result($query,$row,"contact");
 $address=mysql_result($query,$row,"address");
 echo "<tr><td><center>$name</center></td><td><center>$contact</center></td><td><center>$address</center></td></tr>";
 $row++;//increase by 1;
 }
echo "</table>";
?>
</body>
</html>

I got the whole table data in the above code. But i dont want that .What i am trying to do here is .

In the top center i need a dropdown with two options say : Type1 and type2.

When user select type1 it need to generate another dropdown with name "Please choose name" and when user select type2 it need to generate 2 dropdown with name "please choose name" and "Please choose address".

Please choose name should have values from the table column name.
Please choose address should have values from the table column address.
eg: select distinct(name) from personal.

I just want them to load in the same page and provide o/p.

Thanks
ASKER CERTIFIED SOLUTION
Sar1973

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros