|
Posted by Erwin Moller on 10/06/06 08:57
rukkie wrote:
> I have a MySql db, in which I search for values to populate a selection
> box, as follows :
>
> <select size="1" name="customer">
> <option selected="selected">(not queried)</option>
Hi Rukkie,
That is wrong.
selected="selected" in nonsense.
If you want to select an option in a selectbox, you only use the word
SELECTED, and don't give it a value.
You'll have to produces something like this:
<SELECT name="customer">
<OPTION value="bla1">bla1
<OPTION value="bla2" SELECTED>bla2
<OPTION value="bla3">bla3
</SELECT>
In your code none of the options have a value.
I would advise you to FIRST learn how HTML and FORMS works, then start PHP.
Regards,
Erwin Moller
> <?php while($nt=mysql_fetch_array($result2)){
> echo "<option value=$nt[customer]>$nt[customer]</option>\n";}
> ?>
> </select>
>
> This works fine, all the customers appear with their complete names,
> including spaces if there are.
>
> When I do a submit of the php page containing this part of code and in
> this page I do a
>
> $customer=$_POST['customer'];
>
> then the value of $customer is cutted to the first <blank> (space)
> encountered.
>
> E,g, : if in the selection box the customer name John Smith appears,
> then I get in the result page after the submission as customer=John
>
> When I make a selection box, with fixed populated values (so values not
> fetched from the db) then after the submission, I get the correct info
> (values are not cutted to the first space).
>
> Is there anybody out there that can give a solution for this strange
> (to me) behaviour ? It would be uttermost appreciated !
[Back to original message]
|