Get help on web editors (Frontpage, Dreamweaver) and web languages (HTML, ASP, PHP).
Ryan_Cooper
Registered User
Posts: 3129 Joined: 22 Sep 2008, 11:16
Location: stuck in my own world
Post
by Ryan_Cooper » 08 Dec 2010, 15:18
Hi guys ...I'm fairly new to PhP and I'm still learning.
I'm trying to build a form that fist gives me a drop down box list of users in a db that I can then submit via POST to another form, but for some reason the names are not pulling into the drop down box.
this is what my code looks like so far:
Code: Select all
<?php
include('config.inc');
$sql="SELECT user FROM member";
$result = mysqli_query($sql);
while ($row = mysqli_fetch_array($result))
{
$id = $row['fuser'];
$item .= "<OPTION VALUE=\"$id\"></option>\n";
}
?>
<body onload="document.edit_user.fuser.focus()">
<form action="nuserform.php" name="edit_user" method="post" >
User: <SELECT NAME="fuser">
<option value=0>Choose
<?php echo $item;?>
</SELECT>
<br />
<input type="submit" value="Select User" target="userframe" />
<input type="reset" Value ="Clear Fields">
</form>
</body>
the file config.inc containsd my db connection strings which is then used in the variable $cxn (i hope i said that right)
any help would be greatly appreciated
THE GAME........YOU Have JUST LOst It !!!!!!!!!!
DeathStrike
Registered User
Posts: 2663 Joined: 29 Jul 2004, 02:00
Location: hidden deep in the depths of the underworld is my home.
Contact:
Post
by DeathStrike » 08 Dec 2010, 15:22
Well your items won't display because you are only filling in the names in the Value fields?
Code: Select all
$item .= "<OPTION VALUE=\"$id\"></option>\n";
should be
Code: Select all
$item .= "<OPTION VALUE=\"$id\">TEXT YOU WANT DISPLAYED</option>\n";
Spoiler: (show )
SIG by HMAN Member of The Pride Of Darkness
DeathStrike on Twitter
About me
Spoiler: (show ) Asus P5KPL-CM motherboard, 4 GIG RAM, Q6600 @ 2.88GHz (Thanks Anthro), GeForce 8600GT, Samsung 2333 23" + CRT 17" Monitors. 500GB + 1.5TB HDD, Compro TV tuner, 350 WATT PSU
-Prometheus-
Resident Drama Llama
Posts: 967 Joined: 05 Mar 2008, 02:00
Contact:
Post
by -Prometheus- » 10 Dec 2010, 00:02
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
Last edited by
-Prometheus- on 03 Apr 2011, 22:52, edited 1 time in total.
BBLounge - Broadband and Technology forum
Please like our facebook
page
Ryan_Cooper
Registered User
Posts: 3129 Joined: 22 Sep 2008, 11:16
Location: stuck in my own world
Post
by Ryan_Cooper » 10 Dec 2010, 09:20
thanks guys
THE GAME........YOU Have JUST LOst It !!!!!!!!!!
Ryan_Cooper
Registered User
Posts: 3129 Joined: 22 Sep 2008, 11:16
Location: stuck in my own world
Post
by Ryan_Cooper » 13 Dec 2010, 10:11
ok guys I got it figured out and it supposed to have been this:
Code: Select all
<?php
include('config.inc');
$sql="SELECT mem_id,user FROM members";
$result = mysqli_query($cxn,$sql);
while ($row = mysqli_fetch_assoc($result))
{
$mem_id = $row['mem_id'];
$user = $row['user'];
$item .= "<option value=$mem_id>$user\n";
}
?>
<body onload="document.edit_user.fuser.focus()">
<form action="nuserform.php" name="edit_user" method="post">
Select a User: <select name="mem_id">
<option value=0>Choose
<?php echo $item;?>
</SELECT>
<br />
<input type="submit" value="Select User" target="userframe" />
<input type="reset" Value ="Clear Fields">
</form>
</body>
THE GAME........YOU Have JUST LOst It !!!!!!!!!!
Ryan_Cooper
Registered User
Posts: 3129 Joined: 22 Sep 2008, 11:16
Location: stuck in my own world
Post
by Ryan_Cooper » 13 Dec 2010, 14:07
thanks RDF...I was wondering why even though it was displaying correctly it wasn't exactly pushing forward like i wanted it too.
THE GAME........YOU Have JUST LOst It !!!!!!!!!!
Ryan_Cooper
Registered User
Posts: 3129 Joined: 22 Sep 2008, 11:16
Location: stuck in my own world
Post
by Ryan_Cooper » 14 Dec 2010, 09:37
I have one more question...
How do I get the form that loads when you hit submit to load in a new frame and not in the same frame?
THE GAME........YOU Have JUST LOst It !!!!!!!!!!
Ryan_Cooper
Registered User
Posts: 3129 Joined: 22 Sep 2008, 11:16
Location: stuck in my own world
Post
by Ryan_Cooper » 14 Dec 2010, 10:27
thanks ...I had that in once and it didnt work so I changed it back .....i guess I must not have reloaded the script or waited long enough for it to reload
THE GAME........YOU Have JUST LOst It !!!!!!!!!!