Drop Menu

Started on the old forum in May 2010 · view the original in the archive · old links redirect here

10 replies · 760 views · started 16 years ago · 1 min read

3 participants
wap_king Developer · 126 posts #1

how to make a drop menu stay selected and i dnt have to re-select everytime i update my profile..for example

echo "Gender: ";

echo "<select name="sex">";

echo "<option value="N/A" >N/A</option>";

echo "<option value="Male" >Male</option>";

echo "<option value="Female" >Female</option>";

echo "</select>";

if i select male how do i make it stay at that one?

GumSlone Administrator Principal · 1,690 posts #2

wap_king wrote: how to make a drop menu stay selected and i dnt have to re-select everytime i update my profile..for example

echo "Gender: ";

echo "<select name="sex">";

echo "<option value="N/A" >N/A</option>";

echo "<option value="Male" >Male</option>";

echo "<option value="Female" >Female</option>";

echo "</select>";

if i select male how do i make it stay at that one?

you can use cookies to save which options user has selected.

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

wap_king Developer · 126 posts #4

Gum i dont knw cookie and something else i used selected and it didnt work can u give me an example ?

something else Fellow · 2,296 posts #5

cant remember ibwf_users sql but something like this:

$sex = mysql_fetch_array(mysql_query("SELECT sex FROM ibwf_users WHERE id='".$who."'"));

echo "<b>Gender</b>:<br/>";
echo "<select name=\"sex\">";
echo "<option value=\"N/A\" >N/A</option>";
if($sex[0]=="Male"){
echo "<option value=\"Male\"  selected=\"selected\">Male</option>";
}else{
echo "<option value=\"Male\">Male</option>";
}
if($sex[0]=="Female"){
echo "<option value=\"Female\"  selected=\"selected\">Female</option>";
}else{
echo "<option value=\"Female\" >Female</option>";
}
echo "</select>";

or something simular to it 😛

wap_king Developer · 126 posts #6

i think i tried sumting like that and it didnt work mayb i missed sumting let me try that......even thou i see ibwf_users there so i guess thats lavav coding dnt think its gonna work on my script got 2 recode that

wap_king Developer · 126 posts #7

hey i got it thanx.....for the help something else

wap_king Developer · 126 posts #9

Am having problem with this one thou......check it out

echo "Looking For: ";

echo "<select name="looking">";

echo "<option value="N/A" >N/A</option>";

$data = mysql_fetch_assoc(mysql_query("select * from pg_user where login ='$user'"));

if($data['looking[0]']=="1"){ echo "<option value="1" selected="1">Dating</option>"; }else{ echo "<option value="1">Dating</option>";

}

if($data['looking[0]']=="2"){ echo "<option value="2" selected="2">Serious Relationship</option>"; }else{ echo "<option value="2" >Serious Relationship</option>"; }

if($data['looking[0]']=="3"){ echo "<option value="3" selected="3">Friends</option>"; }else{ echo "<option value="3" >Friends</option>"; }

echo "</select>";

something else Fellow · 2,296 posts #10

Providing the variable $user is defined should be something like this:

 
echo "<b>Looking For</b>:<br/>"; 
echo "<select name=\"looking\">"; 
echo "<option value=\"N/A\" >N/A</option>"; 
$data = mysql_fetch_assoc(mysql_query("select looking from pg_user where login ='".$user."'"));
if($data[0]=="1"){ 
echo "<option value=\"1\" selected=\"1\">Dating</option>"; 
}else{ 
echo "<option value=\"1\">Dating</option>"; 

}
if($data[0]=="2"){ 
echo "<option value=\"2\" selected=\"2\">Serious Relationship</option>"; 
}else{ 
echo "<option value=\"2\" >Serious Relationship</option>"; 
}
if($data[0]=="3"){ 
echo "<option value=\"3\" selected=\"3\">Friends</option>"; 
}else{ 
echo "<option value=\"3\" >Friends</option>"; 
} 
echo "</select>";
wap_king Developer · 126 posts #11

nope thats not gonna work...thanx for trying......

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close