Myspace Layouts - WoW Gold - Debt Consolidation - Self Improvement Articles Directory - Sport Betting

PDA

View Full Version : Confusing Coding Help.


NuWeb.co.uk
Oct 30th 2005, 3:43 pm
Here is a SNIPPET of my codeing:
<select name="newcountry" id="newcountry">
<option <? $val="Afganistan"; echo "value=\"".$val."\""; if ($country == $val) echo "selected"; ?>Afghanistan</option>
<option <? $val="Albania"; echo "value=\"".$val."\""; if ($country == $val) echo "selected"; ?>Albania</option>
</select>

This is the HTML output:
<select id="newcountry" name="newcountry">
<option value="Afganistan" selected option Afghanistan<></option>
<option value="Albania" option Albania<></option>
</select>

Get it? .. I dont.. Well confused.

Point of this code?
This is going to be a form, which people can select their country, and submit it to a html databse. All that works. The php codeing in the form is theire to set it so, if a user sets their country to UNITED KINGDOM when they go to edit their profile, their country is still UNITED KINGDOM :)

frankm
Oct 30th 2005, 4:02 pm
Add an extra > after ?> on line 2 and 3 and a space between " and selected.

frankm
Oct 30th 2005, 4:04 pm
or copy and paste:

<select name="newcountry" id="newcountry">
<option <? $val="Afganistan"; echo "value=\"".$val."\""; if ($country == $val) echo " selected"; ?>>Afghanistan</option>
<option <? $val="Albania"; echo "value=\"".$val."\""; if ($country == $val) echo " selected"; ?>>Albania</option>
</select>


outputs

<select name="newcountry" id="newcountry">
<option value="Afganistan" selected>Afghanistan</option>
<option value="Albania">Albania</option>
</select>

NuWeb.co.uk
Oct 30th 2005, 4:05 pm
frankm...
You wont beleave how long ive been trying to sus that out :)
lol... Thanks allot man.