Me again, hope you don’t mind!
For firstChoice and secondChoice, these values are entered from a form and show up in the column seperated by commas for example first choice could be “Tennis, Netball” and second “Football, Swimming, Badminton”.
I can update the name values but not the checkboxes. Any help? I will post how I inserted them in the first place if it helps
THE EDIT.PHP PAGE
[php]$action = isset( $_POST[‘action’] ) ? $_POST[‘action’] : “”;
if($action == “update”){
try{
$query = “UPDATE table1
SET userID = :userID, name = :name, firstChoice = :firstChoice, secondChoice = :secondChoice
WHERE userID = :userID”;
$stmt = $con->prepare($query);
$stmt->bindParam(':userID', $_POST['userID']);
$stmt->bindParam(':name', $_POST['name']);
$stmt->bindParam(':firstChoice', $_POST['firstChoice']);
$stmt->bindParam(':secondChoice', $_POST['secondChoice']);
$stmt->bindParam(':id', $_POST['id']);
$stmt->execute();
echo "Updated!";
}catch(PDOException $exception){ //to handle error
echo "Error: " . $exception->getMessage();
}
}
try {
$query = “select userID, name, firstChoice, secondChoice from table1 where id = ? limit 0,1”;
$stmt = $con->prepare ($query);
$stmt->bindParam('1', $_REQUEST['id']);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$userID = $row['userID'];
$name = $row['name'];
$firstChoice = $row['firstChoice'];
$secondChoice = $row['secondChoice'];
$id = $row['id'];
}catch(PDOExcepton $exception) {
echo "Error: " . $exception->getMessage();
}
?>[/php]
AN EXAMPLE OF THE ARRAY FROM THE INSERT.PHP PAGE
[php]if (isset($_POST[‘firstChoice’]) && is_array($_POST[‘firstChoice’])) {
$firstChoiceCB = join (’, ', $_POST[‘firstChoice’]);
}
else $firstChoiceCB = ‘’;[/php]