I ask for help as i have been stuck for days on a solution.
I have a form that submits a load of checkboxes - This works fine.
I then have a form i can open which will display said checkboxes and will be checked or not checked based on the sql query ran.
SQL query runs ok with echo but i cannot get the box to show as checked. After this i want to be able to check uncheck the boxes and update via an SQL.
<?php
session_start();
ini_set('display_errors', 1); error_reporting(-1);
$data = $_GET['id'];
require 'connect.php';
$sql1 = "SELECT id, phone, email, pager
FROM [dbo].[preference] WHERE id = '$data'";
$stmt1 = sqlsrv_query($con,$sql1);
if( $stmt === false) {
die( print_r( sqlsrv_errors(),true));
}
while ($row1 = sqlsrv_fetch_array($stmt1)){
$phone = $row1['id'];
$phone = $row1['phone'];
$email = $row1['email'];
$pager = $row1['pager'];
}
?>
<td><input type="checkbox" name="phone" class="check" value="1">phone</td>
<td><input type="checkbox" name="email" class="check" value="1">email</td>
<td><input type="checkbox" name="pager" class="check" value="1">pager</td>
If anyone knows of any good links or videos where i can find an answer or knows how to do this i would be grateful. thanks.
Aucun commentaire:
Enregistrer un commentaire