I've been trying for a few days to figure this out but can't get it to work out correctly as I run through testing the scenarios. Basically, this is on an edit form, so it's pulling the stored value from the database. I have it save as either "1" or "0", 1 being checked. It's also a single checkbox, not an array.
I'm trying to figure out how to make the session correctly store the choice of my checkbox so that if there's an error on the page, etc, it shows my session value correctly, but what happens is that the DB value usually ends up trumping that.
So how can I initially first display the DB value, but then display the session value if changed?
Here's what I've been playing with.
if(isset($_SESSION["include_due_date"])) {
$include_due_date = 'checked="checked"';
} else {
if((!isset($_SESSION["include_due_date"])) && $resInvoice[0]["include_due_date"] == 1 ) {
$include_due_date = 'checked="checked"';
} elseif((isset($_SESSION["include_due_date"])) && $resInvoice[0]["include_due_date"] == 0 ) {
$include_due_date = 'checked="checked"';
} elseif((!isset($_SESSION["include_due_date"])) && $resInvoice[0]["include_due_date"] == 0 ) {
$include_due_date = '';
}
}
Any ideas?
Aucun commentaire:
Enregistrer un commentaire