Re: Question: Repopulating form parameters
| From: | Stuart Felenstein | Date: | Sun, 12 Dec 2004 11:32:32 +0000 |
| Subject: | Re: Question: Repopulating form parameters | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-204093@lists.php.net to get a copy of this message | ||
--- Jason Wong <php-general@gremlins.biz> wrote:
> On Sunday 12 December 2004 18:15, Stuart Felenstein
> wrote:
>
> > Still stuck on this one. I know I'm doing
> something
> > wrong and wouldn't mind some correction:
>
> Did you mockup some test HTML in a wysisyg editor as
> suggested?
Yep like this :
<select name="select" size="10" multiple>
<option value="1" <?php if (!(strcmp(1,
"None"))) {echo "SELECTED";} ?>>Black</option>
<option selected value="2" <?php if
(!(strcmp(2, "None"))) {echo "SELECTED";}
?>>Blue</option>
<option value="3" <?php if (!(strcmp(3,
"None"))) {echo "SELECTED";} ?>>Red</option>
<option value="4" <?php if (!(strcmp(4,
"None"))) {echo "SELECTED";} ?>>Orange</option>
<option value="5" <?php if (!(strcmp(5,
"None"))) {echo "SELECTED";} ?>>Purple</option>
<option selected value="6" <?php if
(!(strcmp(6, "None"))) {echo "SELECTED";}
?>>Brown</option>
</select>
Problem is arrays are hanging me up.
> Did you compare the mockup HTML with that produced
> by your code above?
//mockup
<option value="<?php echo
$row_rsInd['CareerIDs']?>"<?php if
(!(strcmp($row_rsInd['CareerIDs'], 2))) {echo
"SELECTED";} ?>><?php echo
$row_rsInd['CareerCategories']?></option>
//Attempt, problems with parsing errors:
<select name="Ind[]" size="8" multiple="multiple"
id="Ind[]" >
<?php
while($row = mysql_fetch_array($inds, MYSQL_BOTH)) {
echo '<option value="'.$row['CareerIDs'].'">';
if (!(strcmp($row_rsInd['CareerIDs'], '$Ind')));
{echo "SELECTED";}
.$row['CareerCategories'].'</option>';
}
Close but no cigar. Since $Ind is already imploded my
thinking is it need not be incremented in the echo
statement ?
Stuart