Search code examples
phpmysqlrowtabular

How to print checkboxes according to total days?


I having problem to print out check box according to booth and total days. Brief story: I have 4 booths, name A1, A2, A3 and A4. I want to let customer booking my booths. Customer can choose which day they want to book.Sometimes the booths available to book for 7 days, sometimes 15 days. Now I want to display my booths according to total days, if booths available for 15 days, then it will display:

Booth Availability Overview

if available for 7 days, then it display only 7 checkbox each row.

In my database I store booth, totalDay and D1-D15 as single field. How to print the above pattern in PHP?

table structure enter image description here


Solution

  • The general idea is something like this:

    $booths = array("Jake", "Amir", "Lilly", "Foo");
    $dayCount = 15; // show checkboxes for 15 days
    foreach ($booths as $booth) {
        echo "Booth $booth: ";
        for ($day = 0; $day < $dayCount; ++$day) {
            echo "checkbox for day $day, ";
        }
    }