Daniel ANderson
Daniel ANderson

Reputation:

Can I BInd One Row of an array to a drop down list?

is it possible to bind one row of an array to a drop down list?

The situation is I have a query that pulls the following data and puts it in an array using php:

student_id class teacher_code times

THe idea is that I want the user to be able to book a time with the teacher of the class and only display the NON Booked times.

Obviously students are in multiple classes so therefore have multiple teachers, the times are in intervals of 5mins over a period of 3 hours.

The issue with the above query is that it displays all the times for all the teachers.

Is it possible to bind that "times" field that is part of the array to a drop down box so that there is only 1 record student_id, class, teacher_code and then times (dropdown menu)?

Upvotes: 0

Views: 243

Answers (1)

KV Prajapati
KV Prajapati

Reputation: 94643

print "<select name='foo'>";
foreach($row as $key=>$value){
  print "<option value='$key'>$value</option>";
}
print "</select>";

Upvotes: 2

Related Questions