mardi 19 janvier 2016

Adding multiple columns values from sql database in a php variable (without using an array name inhtml checkbox tag)

$queryStoreSecondaryInfo = $connection->query($sqlStoreSecondaryInfo);

    if( $queryStoreSecondaryInfo ){
    echo "<br />Updated Secondary! <br />";
    $sqlUpdatedSecondaryInfo = " SELECT * FROM students_skills WHERE ID='$_SESSION[ID]' AND Email='$Email' ";
    $queryUpdatedSecondaryInfo = $connection->query($sqlUpdatedSecondaryInfo);
    while( $row = $queryUpdatedSecondaryInfo->fetch_assoc() ){
    $_SESSION["Landscaping"] = $row["Landscaping"];
    $_SESSION["Cleaning"] = $row["Cleaning"];
    $_SESSION["Delivery"] = $row["Delivery"];
    $_SESSION["Music"] = $row["Music"];
    $_SESSION["Maintenance"] = $row["Maintenance"];
    $_SESSION["Decoration"] = $row["Decoration"];
    $_SESSION["Painting"] = $row["Painting"];
    $_SESSION["PetCare"] = $row["PetCare"];
    $_SESSION["Tutoring"] = $row["Tutoring"];
    $_SESSION["Vehicles"] = $row["Vehicles"];
    $_SESSION["SnowRemoval"] = $row["SnowRemoval"];
    $_SESSION["Other"] = $row["Other"];

    foreach( $row as $skill => $value ){
        $postSkills=array();
        if( $value == "1" ){

            //if statement is true, add all column header names, 
            //ie. $skill values, together, and store in a variable, eg. $postSkills

        }
        echo $postSkills;
    }
}

The SESSION values are coming from multiple checkboxes. I want to concat all names together, in a string, and store it as a session variable. I have seen other solutions and everywhere the response is to set the name of checkboxes as something like "name='array[]'. However, because of how my database is set up, I have to give each checkbox a unique name. Is there anyway to concat all the column header names together, without creating a separate database to store the full list of skills together?

Thanks!




Aucun commentaire:

Enregistrer un commentaire