0

I want two list in the same page. First list will be load while page loading. Every item in this list has a value, i want whenever user choose another item (and another value automaticlly) second list will be loaded.how can i do this via using javascript and php?

example

  1. schools
  2. hospitals

if it choose schools(1) second list must be loaded with school names.

note:i have 2 table on mysql. all i want you to write the website codes.

<select id="first" >
    <?php
$con=mysqli_connect("localhost","root","","cau");


$result = mysqli_query($con,"SELECT id, main FROM first");

while($row = mysqli_fetch_array($result))
  {
  echo "<option value=\"".$row['id']."\">".$row['main']."</option>";
  }     

mysqli_close($con);
   ?>
</select>


<select>

     //how can i load this second list as i said
</select>
2
  • 2
    "all i want you to write"... we are here to help, not do your job for you. Commented Nov 28, 2013 at 19:59
  • you can refer this stackoverflow.com/questions/19756130/… Commented Nov 28, 2013 at 20:03

1 Answer 1

0

If I understand what you are trying to do correctly, you might want to consider using AJAX. The specific tutorial that will help you is: http://www.w3schools.com/ajax/ajax_database.asp It basically lets you select from one list, and once an item is selected, more options, related to the chosen item is shown.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.