I am new to php...i need help. I have 5 tables in my sql database, I would like to create a dropdown that basing on the value of the dropdown, then a specific table/ view is selected..please guide me.. Thank you.
Below is my php script..
DATA QUERY By: Country District County/ Municipality Sub-County/ Municipality
//select database
MySQL_SELECT_db('edudata',$getconnected);
//creating query to excute on the MySQL dbms
$query="SELECT * FROM ;";
// Excute the query above
$erecords=MySQL_Query($query, $getconnected);
echo '<table align="center" cellspacing="3" bgcolor="#d3dbde" cellpadding="3" width="70%"> <tr><td align="left"><b>District</b></td><td align="left"><b>County/ Municipality</b></td><td align="left"><b>Number of Schools</b></td><td align="left"><b>Number of Schools</b></td><td align="left"><b>Number of Female Teachers
</b></td> <td align="left"><b>No. of Male Teachers</b><td align="left"> <b>Female Enrollment</b></td><td align="left"><b>Male Enrollment</b></td> </tr>';
While ($emprecord=MySQL_fetch_array($erecords))
{
Echo '<tr bgcolor="#f6f6f6"><td align="left">'.$emprecord['District']. '</td><td align="left">'. $emprecord['County_Municipality']. '</td><td align="left">'. $emprecord['No_of_schools']. '</td><td align="left">'. $emprecord['Female_Teachers']. '</td><td align="left">'. $emprecord['Male_Teachers'].'</td><td align="left">'. $emprecord['Female_Enrolment'].'</td><td align="left">'. emprecord['Male_Enrollment'].'</td></tr>';
}
echo '</tables>';
MySQL_Close($getconnected);
?>
After Applying your solution, with code below, In get the errors stated in the comments.
<?php
$getconnected=mysql_connect('localhost','**','**', 'edudata');
if(isset($_POST['submit']))
{
$mytableselect=$_POST['mytableselect'];
//select database
//MySQL_SELECT_db('edudata',$getconnected);
mysql_select_db('edudata', $getconnected);
//creating query to excute on the MySQL dbms
$query="SELECT * FROM $mytableselect ";
// Excute the query above
$erecords=mysql_query($query, $getconnected);
echo '<table align="center" cellspacing="3" bgcolor="#d3dbde" cellpadding="3" width="70%"> <tr><td align="left"><b>District</b></td><td align="left"><b>County/ Municipality</b></td><td align="left"><b>Number of Schools</b></td><td align="left"><b>Number of Schools</b></td><td align="left"><b>Number of Female Teachers
</b></td> <td align="left"><b>No. of Male Teachers</b><td align="left"> <b>Female Enrollment</b></td><td align="left"><b>Male Enrollment</b></td> </tr>';
While ($emprecord=MySQL_fetch_array($erecords))
//Echo'<tr bgcolor="#f6f6f6"><td align="left">'.$emprecord['District'].'</td><td align="left">'. $emprecord['County_Municipality']. '</td><td align="left">'. $emprecord['No_of_schools']. '</td><td align="left">'. $emprecord['Female_Teachers']. '</td><td align="left">'.$emprecord['Male_Teachers'].'</td><td align="left">'.$emprecord['Female_Enrolment'].'</td><td align="left">'.emprecord['Male_Enrollment'].'</td></tr>';
Echo '<tr bgcolor="#f6f6f6"><td align="left">'.$emprecord['District']. '</td><td align="left">'. $emprecord['County_Municipality']. '</td><td align="left">'. $emprecord['No_of_schools']. '</td><td align="left">'. $emprecord['Female_Teachers']. '</td><td align="left">'. $emprecord['Male_Teachers'].'</td><td align="left">'. $emprecord['Female_Enrolment'].'</td><td align="left">'. $emprecord['Male_Enrollment'].'</td></tr>';
echo'</tables>';
MySQL_Close($getconnected);
}
?>