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
52
Other forums
Image loading
Hi Developers,
I'm trying to display an image from images/image.gif getting the url from mysq
listing help
Hi,
at first, great new design!!! I like it,
i got a problem,
I want to list so
help with Get_
ok some how this is not working i am not sure what i am doing wrong here but what this does is when
Storing Values taken from a DB...
Using this code it will generate a short list from my database
<?php
mysql_connect
simplexml and xpath - Need some help
Hello,
I am trying to parse an xml which comes back from Amazon and I am trying to know how m
Connect to database that isn't localhost
I am currently doing a small script for a company that doesn't have mySql support on there hosting.
Disable Scrollbar in TableControl
Hello everbody,
please can anybody help me - outherwise i'm going to become desperate :P<
downloading a file as HTML
Hi.
I'm rather confused with forcing a download. I just want to save dynamic content (from $_SESS
mr8m - reverse document
Friends,
I'm trying to reverse a document held by MIRO, but it reports the message balan
Strip Slashes Help
I've got a script that i've downloaded of the net to edit multiple fields from my sql database, and