473,480 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

database values in the combo box

4 New Member
its easy to place an array values in the combo box.
but i need to know how can i do it if i have to retrieve the values from a database.
my platform is PHP MySql. please i need help :(
combo box name=dep_list_selected
database name = dependency.
if i choose value 'A' then the corresponding values of it that are stored in the table should appear in the combo box.
if i choose another option then its respective values should be displayed.
Mar 1 '07 #1
1 3600
hrubos
2 New Member
its easy to place an array values in the combo box.
but i need to know how can i do it if i have to retrieve the values from a database.
my platform is PHP MySql. please i need help :(
combo box name=dep_list_selected
database name = dependency.
if i choose value 'A' then the corresponding values of it that are stored in the table should appear in the combo box.
if i choose another option then its respective values should be displayed.

So you can see it :
Name:
</td>
<?php

$query = "select last_name,first_name
from student
order by first_name ";
$search_stu=mysql_query($query)or die(mysql_error());
$name = array();

//last name into array
while ($rowN = mysql_fetch_assoc($search_stu))
{
array_push($name, $rowN["last_name"]);

}
?>
<?php //list of name ?>
<td>
<select name="name">
<option value=" "></option>

<?php foreach($name as $valueN) { ?>
<option value="<?= $valueN ?>" <? if ($HTTP_POST_VARS['last_name'] == $valueN){ echo "SELECTED";}?>><?= $valueN ?></option>
<? }

?>
Mar 1 '07 #2

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

Similar topics

2
1545
by: Dan Cook | last post by:
Ok... here's the scoop... I've got an unbound form with Serial Number, Building, and Room... all this is in tableA... Now I've got the form setup with building, room and serial number as combo...
6
4426
by: Sebi | last post by:
Hello all, I'm thinking about overwriting the ListItem, so it can contain x additional values (not only one). Has anybody ever tried this? Has someone got an example (C#)? Can DropDownList...
1
1061
by: Ddraig | last post by:
Howdy, I've got a little project going and I am trying to figure out a good way to do this. But since I'm still learning I'm probably missing a few obvious steps. Also not sure if I have my...
1
1034
by: Ddraig | last post by:
Howdy, I've got a little project going and I am trying to figure out a good way to do this. But since I'm still learning I'm probably missing a few obvious steps. Also not sure if I have my...
20
3651
by: MLH | last post by:
120 MyString = "How many copies of each letter do you need?" 150 MyVariant = InputBox(MyString, "How Many?", "3") If MyVariant = "2" Then MsgBox "MyVariant equals the string '2'" If...
2
12415
by: Eric Layman | last post by:
Hi, I have a radio button and a combo box. Upon changing a value for radio button, the combo box values will be dynamically updated. I have an idea on how to go abt doing it but Im stuck...
0
1101
by: tigger | last post by:
Hi there, I have a problem displaying the correct random values extracted from the database. I'm using arrayRandom that stores left250 values and make it appear 90% of the time....
1
1515
by: tremonti92 | last post by:
Hello.. I have a table with a field name called 'Professions'. There are many same multiple values for this field, for example, there are many records with the value 'Doctor' under this field. ...
0
874
by: NothingMore | last post by:
I am using VB .NET and I am stumped as I draw blanks and cant find anything about adding multiple values to a combo box item. Without using external files. Example: (hope this helps a bit) ...
0
7046
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7088
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
6956
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5342
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4783
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4485
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2997
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
183
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.