Jump to content

OPTION VALUE multiple values


joshuaer
 Share

Recommended Posts

Hello I am trying to figure out how to create a drop down that pulls from 3 rows, I can pull a single value with the code below but I cannot figure out how to mull the other values

<?include("sql.php");	include("auth.php");	$UID = $_SESSION['UID'];$sql="SELECT * FROM users where UID='$UID' AND Cnumber != ''";$result=mysql_query($sql);$options="";while ($row=mysql_fetch_array($result)) {	$id=$row["Nname"];	$thing=$row["Nname"];	$options.="<OPTION VALUE=\"$id\">".$thing;}?><SELECT NAME=Nname><OPTION VALUE=0>Choose<?=$options?></SELECT>

so in the dropdown I would need it to pull for each option Nname CNumber address

Edited by joshuaer
Link to comment
Share on other sites

Hi use the below code. As i guessed, you want to show three columns value show in drop down. so just put the three column values by giving one space.Hope you want the same.<?include("sql.php"); include("auth.php"); $UID = $_SESSION['UID'];$sql="SELECT * FROM users where UID='$UID' AND Cnumber != ''";$result=mysql_query($sql);$options="";while ($row=mysql_fetch_array($result)) { $id=$row["Nname"]; $thing=$row["Nname"]; $options.="<OPTION VALUE=\"$id\">".$thing." ".$row["CNumber"]"." ".$row["address"]."</option>";}?><SELECT NAME=Nname><OPTION VALUE=0>Choose<?=$options?></SELECT>

Link to comment
Share on other sites

thanks for the reply with the code above I am gttin this error Parse error: syntax error, unexpected ';' in /homepages/37/d381229304/htdocs/go-servers/icloud/addressbook.php on line 17

<?phpinclude("sql.php");include("auth.php");$UID = $_SESSION['UID'];$sql="SELECT * FROM users where UID='$UID' AND Cnumber != ''";$result=mysql_query($sql);//$options="";while ($row=mysql_fetch_array($result)) {$id=$row["Nname"];$thing=$row["Nname"];[/b][b]$options.="<OPTION VALUE=\"$id\">".$thing." ".$row["CNumber"]."".$row["address"]."</option>";}?><SELECT NAME=Nname><OPTION VALUE=0>Choose<?=$options.?></SELECT>
Link to comment
Share on other sites

one more question, with the drop down selecting the 3 rows I am using this as a sort of address book. The users load the Nname Cname and address on another page then when they are filling out a form I want them to be able to use the drop down to make a selection. So is it possible to have it post that information it is pulling back into the database into the 3 different rows? Nname Cname address

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...