SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2011
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Select records from a table using checkbox

    Hello All,
    I have a weird requirement on a PHP app.

    I have a table that is showing students that have taken a course in the past. The tables are setup like this
    table 1: SCHEDULED COURSES
    table 2: COURSE REGISTRATIONS (shows students that have registered for scheduled courses)
    table 3: STUDENTS

    The table right now shows students that took a specific scheduled course. All students get listed.
    I need to tick each student that the instructor needs to print a card for (may or may not be all students) and then run a query to select only those students and export those to an excel spreadsheet.

    Obviously its not as easy as doing a SELECT STUDENT ID because it needs to pull information specific to each course. I guess a LEFT JOIN would work but how to I work tick boxes into a query on the following page?

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    The html page showing the checkboxes would evolve from a join as you say.

    You want student id and student name in order to output your check boxes eg:

    Code:
    <input type=checkbox name=students value=student[23] /> Barbara Streisand <br />
    resulting from:

    Code:
    SELECT s.student_id as id, s.student_name as name
    FROM students_table as s
    LEFT JOIN course_registrations_table as r
    ON s.students_id = r.students_id
    ORDER BY students_name
    Where my student_id fields are obviously the ones you want to join on. As you provided no db schema, I guessed some column names to illustrate.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •