For very beginners It is not easier to display data from required
mysql table into combobox in PHP. Again after call any javascript
function from that control’s onClick which will submit the page, always
display only first or last data into combobox as well as it takes same
value as input which bother developers. So in php there is easier way to
handle such a problem. I have a table named casa_session from where I
have to display session_title into select field. The codes are follows:
<? include(“connection.php”) ?>
<TR HEIGHT=”25″>
<TD colspan=”2″>Semester</TD>
<TD>
<select name=”salSemesterID” onClick=”submitCboSemester();”>
<?php
$query_disp=”SELECT * FROM casa_semester order by semester_id asc”;
$result_disp = mysql_query($query_disp, $conn);
while($query_data = mysql_fetch_array($result_disp))
{
?>
<option value=”<? echo $query_data['semester_id']; ?>”<?php
if ($query_data['semester_id']==$_POST['salSemesterID'])
{?>selected<? } ?>><? echo $query_data['name'];
?></option>
<? } ?>
</select>
</TD>
Sumber : http://afruj.wordpress.com/2008/06/26/display-data-from-mysql-into-combobox-in-php/
Tidak ada komentar:
Posting Komentar