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.
Did you know?Explore Trending and Topic pages for more stories like this.

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

Any help with my email script?
I have an email script, I have not tested it, although someone tested it for me and said it worked f

Call to undefined function mysql_fetch_accoc()
New to php/mysql coding. What's wrong with this sequence, or am I
just not seeing to obvious?

Program with calculate Meteorologic measurements
Hello I'm a beginner and I want to make a program with calculate Meteorologic measurements:
ba

DELETE rows based on content
I have a link in my rows

$bit="http://bit.ly/abcd";
$query = mysql_query("D

array empty
Hiya peeps,

Ok here is the codes.

order.php

Code:

sql error
I have been looking at this code for 20mins and can't work out what I am doing wrong. There is somet

having probem inserting data into db table
hi

i have a table with following columns in it
Code: candidate_id, degree, cgpa, institute

PHP - HTTP Digest Authentication - Understanding Code Help
Hi Everyone,

This is my first time on your website and please excuse if I am asking silly que

Need help in log in and log out?
hi there all of u. i have recently created a site for someone. i have placed log in and log out and

user administration
Dear @all,

what I have to do to set the user defaults for new users. At the moment I woul

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