You are here: Re: How do you do selected in a multi-value list box in a form? « PHP Programming Language « IT news, forums, messages
Re: How do you do selected in a multi-value list box in a form?

Posted by rich on 11/20/87 11:48

Here is the form I designed.
This form is to take a dressing type and choose all the wound stages it
can be used on.
there are 3 tables

dressing type table
dresstypeid
dressingtype

stages table
stageid
stage

dressingcat table
dresstypeid
stageid

<form name="dresstypeform" method="post" action="<?php print
$_SERVER['PHP_SELF']?>">
<?php
$dresstypeid = $_REQUEST['dresstypeid'];
if ($dresstypeid >0) {
$drtresult = specificdresstype($dresstypeid); // query for the
specific dressing type
$dresscat = specdresscat($dresstypeid); //query for the wound stages
for a dressing type
$drtyperow = pg_fetch_array($drtresult);
?>
<input type=hidden name="dresstypeid" value= "<?php echo
$drtyperow["dresstypeid"]?>">
<?php
}
?>
<input type=hidden name="dresstypeid" value= "<?php echo
$drtyperow["dresstypeid"]?>">
<fieldset>
<legend>Dressing Type Information</legend>
<table align="left">
<tr>
<td><label for "dresstype">Dressing type</label></td>
</tr>
<tr>
<td><input type=text size="50" name=dresstype value = "<?php echo
$drtyperow["dressingtype"]?>" ></td>
</tr>
<tr>
<td><label for "stages">Stages</label></td>
</tr>
<tr>
<td>
<select name="stages[]" multiple="multiple">
<?php
$allstages = allstages(); //query to populate the listbox with all the
stages in the stage table
while ($allstagerows=pg_fetch_array($allstages)) {
$eachstage= $allstagerows["stageid"];
while($drcatrow = pg_fetch_array($dresscat)){
if ($drcatrow["stageid"] == $eachstage){ ?>
<option value=<?php echo $eachstage;?> selected="selected"><?php echo
$allstagerows["stage"]?></option>
<?php }else{ ?>
<option value=<?php echo $eachstage;?>><?php echo
$allstagerows["stage"]?></option>
<?php }
}
}
?>
</select>
</td>
</tr>
</table>
</fieldset>
<table align="left">
<tr>
<td><input type="submit" name="upddresstype" value="Add-Update Dressing
Type" ></td>
</tr>
</table>

</form>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация