Page 1 of 1

Automatic displayfrom select option

Posted: Mon Mar 14, 2011 10:45 am
by ms.Jemi
hi guyz...
Need help!....please...
Here's the problem...
I want to automatically dispaly the table from database when I select from the select option.
Here's my code with a button to display the table...I wat to automatically dispaly without the submit button..I really nid help...please....

Code: Select all

<form name="formState" method="post" action="<?=$_SERVER['PHP_SELF']?>">
College<select name="college">
		<option>Select</option>     
		<option value="CAS">CAS</option> 
		<option value="COA">COA</option> 
		<option value="CBE">CBE</option>
                <option value="CCS">CCS</option> 
		<option value="CED">CED</option> 
		<option value="CEA">CEA</option>
                <option value="CON">CON</option> 
		<option value="STHM">STHM</option> 
		
		
	</select>
        <input type="submit" name="subcol" value="View">
        </form>
 
<?php
if(isset($_POST['subcol'])){
		$colg=$_POST['college'];
		echo $colg;
include("serverConnect.php");
$tempQuery3="Select fldeleccode from tblelections where fldcomid='$comid'";
$resultTemp3 = mysql_query($tempQuery3) or die('Error: '.mysql_error ());
$row4 = mysql_fetch_array($resultTemp3);
$eleccode = $row4['fldeleccode'];
$tempQuery1 = "Select s.fldidnumber,concat( s.fldfname, ' ' ,s.fldmname, '. ' ,s.fldlname ) as fullname,concat(g.fldcourses, ' - ' ,s.fldyear)as cyear from tblcount t,tblstudent s,tblcolleges g,tblelections e where e.fldcomid='$comid' and e.fldeleccode=t.fldeleccode and t.fldidnumber=s.fldidnumber and s.fldcourse=g.fldcourses and g.fldcollegename in (Select fldcollegename from tblcolleges where fldcollegename='$colg')";

$resultTemp1 = mysql_query($tempQuery1) or die('Error: '.mysql_error ());
$num_rows = mysql_num_rows($resultTemp1);

if($num_rows==0)
{
		echo '<br>';
		echo "No student voted in this college!";
}
else{
echo'<table border="1">';
echo '<tr>';

echo '<th>ID Number</th>';
echo '<th>Name</th>';
echo '<th>Course & Yr</th>';
echo '</tr>';



while ($row = mysql_fetch_array($resultTemp1)){
        echo "<tr>";  
 echo "<td>" .$row['fldidnumber']. "</td>";
 echo "<td>" .$row['fullname']. "</td>";
 echo "<td>" .$row['cyear']. "</td>";
 
    
    
 echo "</tr>";
}
echo "</table>";
}
}


        ?>

Re: Automatic displayfrom select option

Posted: Mon Mar 14, 2011 11:38 am
by social_experiment
You should look into AJAX for this :)