473,322 Members | 1,562 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,322 software developers and data experts.

dynamic drop-down list in array

Hello everyone.

Q. How do I create a dynamically-generated drop-down list for use in
an array.

I'm using PHP with a MySQL database (through phpMyAdmin)

My database table is called com_courses, and I want to pull the
distinct 'title' fields and have them appear as a drop down menu for
the user to select in a form.

Here is my array, with (at the moment) manually-entered 'titles'
(which I now need to be dynamically generated from my database field:
'com_courses.title'

array (
"coursetitle",
"Course Title:",
$EXTRA_SELECTLIST,

array ("Report Writing", "Recruitment & Selection", "Presentation
Skills", "Essential Telephone Skills", "Time Managememt", "Customer
Care", "Other"),
0
),

I am not an experienced programmer, but can play around with php to
customize programs. I've read up on arrays (I bought a "Programming
with PHP and MySQL" book, but it just stops short of this problem). I
can't figure this one out.

Is this enough info for you kind people to help me?
ANY real code would be soooooo helpful (so I could paste it in),
because, as I mentioned, I'm good at editing existing code rather than
creating code from scratch. But ANY help/guidance/funny comments would
be appreciated.

Thanks!!

Jonny
Jul 17 '05 #1
1 6475
Jonny Tango wrote:
Hello everyone.

Q. How do I create a dynamically-generated drop-down list for use in
an array.

I'm using PHP with a MySQL database (through phpMyAdmin)

My database table is called com_courses, and I want to pull the
distinct 'title' fields and have them appear as a drop down menu for
the user to select in a form.

Here is my array, with (at the moment) manually-entered 'titles'
(which I now need to be dynamically generated from my database field:
'com_courses.title'

array (
"coursetitle",
"Course Title:",
$EXTRA_SELECTLIST,

array ("Report Writing", "Recruitment & Selection", "Presentation
Skills", "Essential Telephone Skills", "Time Managememt", "Customer
Care", "Other"),
0
),
$myar = array
(
'Option 1', 'Option 2', 'Option 3', 'Option 4',
'Option 5', 'Option 6', 'Option 7', 'Option 8'
);

echo '<select name="myselect">';

for($i = 0; $i < count($myar); $i++)
{
echo '<option value="'.$i.'">'.$myar[$i].'</option>';
}

echo '</select>';

This will generate a select list for you.
I am not an experienced programmer, but can play around with php to
customize programs. I've read up on arrays (I bought a "Programming
with PHP and MySQL" book, but it just stops short of this problem). I
can't figure this one out.

Is this enough info for you kind people to help me?
ANY real code would be soooooo helpful (so I could paste it in),
because, as I mentioned, I'm good at editing existing code rather than
creating code from scratch. But ANY help/guidance/funny comments would
be appreciated.
You better learn to get good at creating code from scratch. Not
everthing will be pre-made for you. If that were the case, my job would
be conciderablly easier.

Thanks!!

Jonny


You should study php more before you dive into something as complex as
this. Being able to splice code together and get it to work does not
count, you need some actual experience in writing code. You seem like
you have a fair understanding, therefore a few searches on google and I
think you will pick up on it in no time. Also, for any core function you
can go to http://www.php.net/function_name and get information about
that function (e.g., http://www.php.net/htmlspecialchars).

One last note, do not cross-post into different newsgroups.
comp.lang.php is the appropriate newsgroup for your question 98% of the
time.

Joe Estock
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Guinness Mann | last post by:
When you guys talk about "dynamic SQL," to what exactly are you referring? Is dynamic SQL anything that isn't a stored procedure? Specifically, I use ASP.NET to communicate with my SQL Server...
4
by: MD | last post by:
I am trying to create a dynamic SQL statement to create a view. I have a stored procedure, which based on the parameters passed calls different stored procedures. Each of this sub stored procedure...
31
by: NickName | last post by:
/* goal: dynamic evaluation of table row platform: sql 2000 */ use northwind; declare @tbl sysname set @tbl = 'customers' EXEC('select count(*) from ' +@tbl)
2
by: Mike Moore | last post by:
We are developing an asp.net web application. When we drag and drop the sql connection object to the form we set the in the dynamic properties connection string to use the connection string in the...
7
by: Yaro | last post by:
Hello Is it possible using dynamic SQL in UDF? In Sybase below example work but in DB2 UDB 8.1.3 I get error: "SQL0104N Unexpected element "EXECUTE IMMEDIATE" found....." CREATE FUNCTION...
0
by: Tom Bella | last post by:
We use a lot of dynamic SQL and we use triggers on some tables. We had to drop and create a trigger to make a change and we encountered the error E70081. We have used some harsh methods to...
3
by: MikeY | last post by:
Hi Everyone, I am working in C#, windows forms.My question is this. All my button dynamic controls properties are present and accounted for except for the"FlatStyle" properties. I can't seem to...
1
by: jm | last post by:
I am using (trying) dynamic properties to store a database connection. However, I don't have a connection object on the form. I just do a OdbcConnection in my code. So I can't use the VS IDE to...
2
WhiteRider
by: WhiteRider | last post by:
Hello, I am having some trouble with a guy that has a dynamic IP address. I noticed he is trying to brute-force my SSH account so I used IPtables to drop all incoming packets. The exact command was ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.