I've got, in this case, 4 radio buttons in a form. In a previous step a user gets to choose between options (like A, B, C, D) that include different radios being selected. Eg: Choose A and radio 1 is selected, and so on. This choice is saved in mysql as
// If B:
Customer Prod Group Chosen
12345 1 1 0
12345 2 1 1
12345 3 1 0
12345 4 1 0
For later use in some other weird IT system, I need to save the non selected as 0
.
Later the user can visit this page again. I then check the database to mark the correct radio as checked
.
Problem
The user must not make the initial choice.
Since the user must not make a choice (A, B...) I'm having trouble with the sql query when it's returning an empty result (no choices found). I save the sql result to $p
in this case and then check if it's 1 or 0/empty.
<input type="button" <?= empty($p[0])?'':'checked';?> />
<input type="button" <?= empty($p[1])?'':'checked';?> />
<input type="button" <?= empty($p[2])?'':'checked';?> />
<input type="button" <?= empty($p[3])?'':'checked';?> />
This results in the first 3 radios being checked.
Any idea how to tackle this?
I somehow need to check if the sql entry is 1
(chosen), 0
(not chosen)or not present at all.
The SQL is just a simple query:
$sql = "
SELECT chosen
FROM choices
WHERE group = 1
AND customer = 12345";
Edit:
var_dump($result)
says bool(false). Is this normal?