473,320 Members | 2,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problems populating form select list dynamically

Gyro
2
Hi all, I'm a php newbie and have read various posts/articles on populating select lists dynamically from a db table. However, I cant seem to get it working in the way I want...

I have 3 select lists on a form and want to use a single piece of code to display each one by passing the relevant query to the code. My problem is that I dont know which mysql_fetch command to use because I cannot access each item by name only number (as the name will change depending on which table I use).

Which loop structure is best?

Currently I'm using...

$country_query = "select coutry_name from country";
$countrys = $conn->query($country_query);
$country_list = mysqli_fetch_object($countrys)

...

case "Country":
$select_list = $country_list;
break;

...

foreach ($select_list as $eachitem) {
?>
<option value="<?php echo $eachitem ?>"> etc.
<?php } ?>

...

Which only gives me one item in each of the select boxs!!! where r the others? How can I get all the countries listed?

Thanks in advance!
Apr 26 '07 #1
1 1247
Gyro
2
Well I managed to solve it...

Used while ($eachitem = mysqli_fetch_array($select_field)) where $select_field is equated to the query result! then accessing $eachitem[0] gives me the values I want.

Cool
thanks for reading!!
Apr 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: B. G. Mahesh | last post by:
hi In the registration form I have city, state, country fields. I was wondering if there was a database available on the net which has the list of states in each of the countries. That way when...
3
by: daveland | last post by:
I am working on some JavaScript that dynamically adds rows to a table in response to a button click. A new row does appear on the screen when the button is clicked. However, that table to which a...
4
by: bobsawyer | last post by:
I've been building a series of SELECT lists that are populated dynamically using HTTPRequest. Things are going pretty well, and I've got the whole thing working flawlessly in Mozilla/Firebird....
2
by: John Ninan | last post by:
I am creating Dynamic Usercontrol in Asp.net application. In this application I have a combobox(aspx Page). Which contains various items. Based on item selected I am dynamically populating...
3
by: sck10 | last post by:
Hello, I am creating a form for users to enter information about a lab and the members of the lab. I have one form (FormView) that they use to enter information about that lab. The keyvalue is...
4
by: assgar | last post by:
Hi I am stuck on a problem. I use 3 scripts(form, function and process). Development on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. The form displays...
6
by: eureka | last post by:
Hi friends, I am developing a web application using Jsp and JS. I have a main Jsp page(Jsp1).Inside it I have an iframe having an Html- table which is created dynamically and contains all...
0
by: koonda | last post by:
Hi all, I have a Project due after one week. It is a web service project. I have a Web Form which communicates to the web service and this web service communicates to the database. I have all my...
2
by: John Kotuby | last post by:
Hi all, I have a page that displays the contents of a business document in HTML that uses multiple select queries to provide the relevent data. There is a call to the parent table and then...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.