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

Is there a function ... auto send IP
Is there some function that can be sent to a ddns service that returns the ip address of a ddns forw

Displaying values from a SQL count...
Hi,
Easy enough question i just forget the exact method ..
I have ...

Code: //count win

newbie question about multiple queries
hi everyone,
I'm sorry to ask such a basic question, but I'm young and trying to learn php on my

Agency Business Process
Hi,

I don’t understand the process of the agency business in SAP.

In my

Dynamic memory problem
Hey,

At the beginning of my code, I have this line:

Shape* gShape = 0;

Question about ShowWindow()
Hello....

I'm struggling with sumpin, and I hope y'all can help.

I've got a CFormView

db entry based on primary key
My "topics" table contains 10 entires
*--------------*
topicid topic
------

Hyperlink in PHP to MySQL record
Hello,

I am having trouble as i am new to php. I have connected to the database and I have di

PHP webpage & array print issue
I have this code running, and it works perfectly … however, see my bottom bit about what I see

OOP help
okay so i have a class im making it has everything setup i just need to randomize the 2 variables an

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