Page 1 of 1

text, list box...

Posted: Fri Aug 27, 2004 5:42 am
by sguy
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>

Posted: Fri Aug 27, 2004 10:05 am
by feyd
did you forget to create $status? :?

Posted: Fri Aug 27, 2004 10:45 am
by sguy
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...

Posted: Fri Aug 27, 2004 10:48 am
by feyd
$_POST['status']

Posted: Fri Aug 27, 2004 10:54 am
by sguy
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

Posted: Fri Aug 27, 2004 11:08 am
by Bill H
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.

Posted: Sat Aug 28, 2004 12:22 am
by sguy
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]"; 
      }             
?>">

Posted: Sat Aug 28, 2004 8:15 am
by Bill H
Sorry, I thought I knew what you were asking, but apparently not.
I have no idea what you are trying to find out.

Posted: Mon Aug 30, 2004 1:40 am
by sguy
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>

Posted: Mon Aug 30, 2004 2:35 am
by feyd
what doesn't work about it?

Posted: Mon Aug 30, 2004 2:50 am
by sguy
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...

Posted: Mon Aug 30, 2004 3:03 am
by feyd

Code: Select all

<option value="" selected>Prefer undisclosed</option>
is the reason why the listbox doesn't work. Remove 'selected'

Posted: Mon Aug 30, 2004 8:48 am
by Bill H

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> 
?>