Trouble with a select list


Posted on 16th Feb 2014 07:03 pm by admin

Hello All!
I was wondering if any of you guys could help me with a small problem I'm having!

I'm trying to add a select list to a form on my webpage.

The select list is generated from information stored in a database.

The table has 25 rows in it presently and what I'm trying to do is list only one column of the rows to create a select list.

An example of this:

Populating a select list with all of the names in a member database.

Here is the relevant code:




$ReqQry=" SELECT `traitname` FROM `traitslist` ";
$ReqResult= mysqli_query($cxn , $ReqQry)or die('Ya did it wrong');
$TraitInfo= mysqli_fetch_assoc($ReqResult);
$TraitCnt= mysqli_num_rows($ReqResult);



$list1=$TraitCnt;

echo "Required Skill 1-"."</br>";
echo "<select id='Req1'>";

foreach($TraitInfo as $v)
{
while($list1 > 0)
{
echo "<option value='$v'>$v</option>";
$list1--;
}


}
echo "</select>"."</br></br>";




The problem that I am having is that the select list generates the same entry 25 times.

Any help would be appreciated, as I have fiddled around with it for about two days in my off-time and no luck yet. Thanks
*ps* I'm still rather wet behind the ears with PhP so be gentle

No comments posted yet

Your Answer:

Login to answer
300 Like 52 Dislike
Previous forums Next forums
Other forums

How can i steam a video on my PHP site? (non YouTube)
Basically I have a PHP site and don't want to give page rank to YouTube. I just want to stream a bas

Got A Free Server :(
So I was given a free server

http://shopping.yahoo.com/p:Compaq%20ProLiant%201500%20Server:1

Xacute search within SQL results
I have a query that is pulling data, and I want to return a specific value from the results of that

SOAP Issue
Hi,

I am facing some understanding problem with SOAP basic.kindly recommend some SOAP expert.

Spaghetti Code
So.

I've pretty much reached the point where I have so many isset s on one page that I can't

Reditecting pages based on logic
Newbie here, apologies in advance!

I am trying to use the header function to forward one of a

PHP Mysql Staff Induction System
Hi there, I'm pretty new to PHP and Mysql so could really do with being pointed in the right directi

Need help urgant
why down my code ony return one item instead of all the items selected.

$arr = array($date,$

PHP and Javascript
Hello Everyone,

I have a page that needs a javascript code to be written between PHP code but

PHP Upload issue
Hi guys,

I have stumble across an interesting issue with my script and is doing my head in.

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash