PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
sguy
Forum Commoner
Posts: 61 Joined: Sun Aug 10, 2003 2:44 am
Post
by sguy » Fri Aug 27, 2004 5:42 am
the value can be showed in text box, but can’t show in the list box…
how to show the value in the list box???
thanks...
text box
Code: Select all
<input maxlength=40 size=40 name=fullname value="<? mysql_select_db($database, $conn);
$result=mysql_query("select * from ".$DBprefix."signup where username = '$nickname'") ;
$number_of_array = mysql_num_rows($result);
while ($number_of_array = mysql_fetch_array($result)){
echo "$number_of_array[fullname]";
}
?>">
list box
Code: Select all
<select name=status>
<option value="" selected>Prefer undisclosed</option>
<option value="Single" <?php if(isset($status)&&$status=='Single'){echo('selected');} ?>>Single</option>
<option value="Living together" <?php if(isset($status)&&$status=='Living together'){echo('selected');} ?>>Living together</option>
<option value="Married" <?php if(isset($status)&&$status=='Married'){echo('selected');} ?>>Married</option>
<option value="Separated" <?php if(isset($status)&&$status=='Separated'){echo('selected');} ?>>Separated</option>
<option value="Divorced" <?php if(isset($status)&&$status=='Divorced'){echo('selected');} ?>>Divorced</option>
<option value="Widowed" <?php if(isset($status)&&$status=='Widowed'){echo('selected');} ?>>Widowed</option>
</select>
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Aug 27, 2004 10:05 am
did you forget to create $status?
sguy
Forum Commoner
Posts: 61 Joined: Sun Aug 10, 2003 2:44 am
Post
by sguy » Fri Aug 27, 2004 10:45 am
when user register, he/she need to fill in all the details....
when he/she click "Edit Profile", all his/her personal details will show in textbox and listbox....
then he/she click "Update" button to save back to the database.
the textbox can be showed but i don't know how to retrieve the result in listbox...
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Aug 27, 2004 10:48 am
$_POST['status']
sguy
Forum Commoner
Posts: 61 Joined: Sun Aug 10, 2003 2:44 am
Post
by sguy » Fri Aug 27, 2004 10:54 am
it is not a button, i can post the value to the page that contain textbox & listbox, so i use while loop to select the value in the textbox...
but dont know how to use while loop to select in the listbox
Bill H
DevNet Resident
Posts: 1136 Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:
Post
by Bill H » Fri Aug 27, 2004 11:08 am
The value will be like:
Code: Select all
<?php
if ($_POST['status'] == "Single")
?>
So at the arrival it is pretty much identical and the same process as the textbox should work fine.
sguy
Forum Commoner
Posts: 61 Joined: Sun Aug 10, 2003 2:44 am
Post
by sguy » Sat Aug 28, 2004 12:22 am
Bill H wrote: The value will be like:
Code: Select all
<?php
if ($_POST['status'] == "Single")
?>
So at the arrival it is pretty much identical and the same process as the textbox should work fine.
not very understand....
can use the same method in list box?
Code: Select all
<input maxlength=40 size=40 name=fullname value="<? mysql_select_db($database, $conn);
$result=mysql_query("select * from ".$DBprefix."signup where username = '$nickname'") ;
$number_of_array = mysql_num_rows($result);
while ($number_of_array = mysql_fetch_array($result)){
echo "$number_of_array[fullname]";
}
?>">
Bill H
DevNet Resident
Posts: 1136 Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:
Post
by Bill H » Sat Aug 28, 2004 8:15 am
Sorry, I thought I knew what you were asking, but apparently not.
I have no idea what you are trying to find out.
sguy
Forum Commoner
Posts: 61 Joined: Sun Aug 10, 2003 2:44 am
Post
by sguy » Mon Aug 30, 2004 1:40 am
i've tried this on my own pc, it works....
when i upload to my web host, it doesn't work....
any problems???
Code: Select all
<? echo'<a class=hp href=edit.php?education='.urlencode($row[education]).'>Edit Profile</a>';?>
Code: Select all
<select name=education>
<option value="" selected>Prefer undisclosed</option>
<option value="High School"<?php if(isset($education)&&$education=='High School'){echo('selected');} ?>>High School</option>
<option value="College"<?php if(isset($education)&&$education=='College'){echo('selected');} ?>>College</option>
<option value="Bachelor"<?php if(isset($education)&&$education=='Bachelor'){echo('selected');} ?>>Bachelor</option>
<option value="Master"<?php if(isset($education)&&$education=='Master'){echo('selected');} ?>>Master</option>
<option value="PhD"<?php if(isset($education)&&$education=='PhD'){echo('selected');} ?>>PhD</option>
<option value="Other"<?php if(isset($education)&&$education=='Other'){echo('selected');} ?>>Other</option>
</select>
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Aug 30, 2004 2:35 am
what doesn't work about it?
sguy
Forum Commoner
Posts: 61 Joined: Sun Aug 10, 2003 2:44 am
Post
by sguy » Mon Aug 30, 2004 2:50 am
the drop down menu show the first value only...
"Prefer undisclosed"
should be same with the value in my database
in the first page, i pass the 'education' value (for example, Master) to second page, then the drop down menu should be Master...
it works on my own machine, but can't work in web host...
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Aug 30, 2004 3:03 am
Code: Select all
<option value="" selected>Prefer undisclosed</option>is the reason why the listbox doesn't work. Remove 'selected'
Bill H
DevNet Resident
Posts: 1136 Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:
Post
by Bill H » Mon Aug 30, 2004 8:48 am
Code: Select all
<?php
<select name=education>
<option value="" <?php if(!isset($_POST['education']) || $_POST['education']=='') {echo('selected');} ?>>Prefer undisclosed</option>
<option value="High School"<?php if(isset($_POST['education']) && $_POST['education']=='High School') {echo('selected');} ?>>High School</option>
//etc
</select>
?>