jeudi 23 juin 2016

Create checkboxes(table) from mysql table

I want to write out details from MySQL database to checkboxes. And the checkboxes structure should look like 6*6 square. ( 6 in one row, 6 in one column).

MySQL database looks like :

|id|package|
|1 |HEI    |
|2 |TAG    |
|...|

I wrote this function (in php)

function getPackages3()
{
    $con = openLockMySQLdb('labcom', 'packages', 'READ');

    $q = mysql_query("SELECT id, package FROM packages ORDER BY package ASC", $con);
    while($row = mysqli_fetch_array($q)) {
        $packages .= '<ul>' . '<li>' . '<label>' . '<input type="checkbox" class="packages_2" id="tab_packages" name="' . $row['package'] . '" value="' . $row['id'] . '-' . $row['package'] . '">' . '<p class="checkbox_label">' . $row['package'] . '</p>' . '</label>' . '</ul>' . '</li>';
    }

    closeUnlockMySQLdb($con);

    return $packages;
}

to get in checkboxes, it's working but i can't but 6 in one row and 6 in one column. So i can't make a square from the checkboxes.




Aucun commentaire:

Enregistrer un commentaire