getting multiple values and outputting them in an option box

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

getting multiple values and outputting them in an option box

Post by a94060 »

hi

i have a table called 'homework' and inside i got"id,teacher,period,course_id"

i want to output the the teacher and course id as an option box so it will be like:


BOXHERE
teacher,course_id
teacher,course_id
teacher,course_id
teacher,course_id


Will it be able to be done something liek this?
i first start the option box(i will look into that)

Code: Select all

foreach($thing as $option) {
echo'<option>$option</option>';
}
hnawri
Forum Newbie
Posts: 1
Joined: Wed Feb 22, 2006 3:05 am

Re: getting multiple values and outputting them in an option

Post by hnawri »

a94060 wrote:hi

i have a table called 'homework' and inside i got"id,teacher,period,course_id"

i want to output the the teacher and course id as an option box so it will be like:


BOXHERE
teacher,course_id
teacher,course_id
teacher,course_id
teacher,course_id


Will it be able to be done something liek this?
i first start the option box(i will look into that)

Code: Select all

foreach($thing as $option) {
echo'<option>$option</option>';
}
<?
$sql = "SELECT teacher,course_id FROM homeworks";
$result = mysql_query($sql);
?>

<select name='blabla'>

<?while($row = mysql_fetch_row($result) echo "<option value='blabla'>$row[0] - $row[1]</option>";?>
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

Post by a94060 »

that will work for a drop down bow right?
Post Reply