Hi
First of all sorry for my English
I'm new here and Im a php coding newbie..i'm currently testing
doing a simple program for xoops cms...
i'm having trouble with this can anyone help me
ok i have this
two table
info_unit : log_id, occupation
myocc : id, occ_list
input
the above code working properly...the drop down will display value from myocc..PHP Code:
<select name='occupation'>
<option value="">Sellect Occupation</option>
<?php
global $xoopsDB;
$result = mysql_query("SELECT * FROM ".$xoopsDB->prefix("myocc")."");
while($row = mysql_fetch_array($result))
{
$occ_list=$row['occ_list'];
$occupation=$occ_list;
echo "<option value='$occupation'>$occ_list</option>";
}
?>
</select>
and the value is submitted to info_unit table successfully
the problem is this code below when i want to edit a record in the edit form
the value that i selected in the input form is not selected
update record
PHP Code:
<?php
$log_id=$_POST[log_id];
if($log_id=='')
{
echo "<center>Please Select a record</center><br /><br />";
}
else
{
$result = mysql_query("SELECT * FROM info_unit WHERE log_id=$log_id");
while($row = mysql_fetch_array($result))
{
$log_id=$row['log_id'];
$occupation=$row['occupation'];
}
?>
<select name='occupation'>
<option value=''>Select occupation</option>
<?php
global $xoopsDB;
$result = mysql_query("SELECT * FROM ".$xoopsDB->prefix("myocc")."");
while($row = mysql_fetch_array($result))
{
$occ_list=$row['occ_list'];
if($occupation == '$occ_list') {
echo "<option value='$occupation' selected>$occ_list</option>";
}
else
{
echo "<option value='$occupation'>$occ_list</option>";
}
}
?>
</select>



Reply With Quote
Bookmarks