Hi all,
First I will explain my problem. I have a form to fetch records as per criteria of the user. The records fetched are to be displayed in tabular form. There are in all 4 fields. One of the fields has to be drop-down list. In the following code, I am using the function to show the fetched records.
Can anybody help me to rectify this code? Can anybody give me suggestion, as how to learn and practice such type of coding pattern?
Any good, useful links for tutorials.
Following is the code :
<?php
FUNCTION print_entry($row)
{
$numargs = func_num_args();
for ($i=1; $i< $numargs; $i++)
{
$field = func_get_arg($i);
$dbvalue = $row[$field];
if ($i == 2)
{
$med_type_id_v = $row[med_type_id];
$med_query = "SELECT med_type_name
FROM media_type_m
WHERE med_type_id = $med_type_id_v";
$med_result = mysql_query($med_query) or die ("Query is not proper.");
$med_row = mysql_fetch_array($med_result);
$med_type_name_v = $med_row[med_type_name];
echo "<TD align=left> <SELECT NAME=med_type_id_array[]>";
$query = "SELECT * FROM media_type_m
ORDER BY med_type_id";
$result = mysql_query($query) or die ("SELECT failed.");
/ The following list item is added to have current value of the med_type_id which is obtained from the database. This will be the very first choice, and will get used when the user does not want to modify/change the value of med_type_id. /
<OPTION value=<?php echo $med_type_id_v ;?> > <?php echo $med_type_name_v ; ?>
</OPTION> ;
/ Append media types present in the media_type_m below the current value. /
while ($list = mysql_fetch_array($result))
{
if($list[med_type_id] != $med_type_id_v)
{
<OPTION value= <?php echo $list[med_type_id] ; ?> >
<?php echo $list[med_type_name] ; ?> </OPTION> ;
}
}
</SELECT>
</TD>" ;
}
else { echo "<td align=left class=text> $dbvalue </td>"; }
}
}
}
?>