2 check box questions

They have: 461 posts

Joined: Jul 2003

1: i have a form i want to display for a user to update choices, right now i'm going to ignore arrays they don't recheck, but since they arrays display as checkboxes that have varying amounts on each row, and some rows wont be complete (as in i only have 2 things on the rown that has 5 columns), i'm trying to think of a way to populate these as selected when making the page.

the values are held in a sql db

any ideas or advice greatly appreciated

********

2:also with this, since i'm making the db for the site tomorrow so i haven't exactly played around with it yet....

when getting an array in the post input from html, since i have the variable in html as name="variable[]"
if i wanna php vatiable to become the array, is it $variable=$_POST['variable']; or $variable=$_POST['variable[]']; ?

POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

1 - huh?
2 - $var = $_POST['var'];

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

1. Set a flag, or some way to tell that the item is checked (obviously).

Check whether the item is checked.

<?php
if ($checkboxflag == \"y\") {
  
$checked = 'checked=\"checked\" ';
   }
else {
  
$checked = '';
   }
echo \"
<input name=\\"
setofcheckboxes[]\\" value=\\"\\" type=\\"checkbox\\" $checked/>
?>

They have: 461 posts

Joined: Jul 2003

remember the signup page i've shown here?

well the itnerests are stored as a string (i didn't see anything that looked appropriate for arrays). the issue is NOT turning the strings back into arrays, but rather the fact i can't think of a way to test thesewithout going in and out of html when creating the page. i'm trying to use the
echo <<blah blah

<?php
blah blah
?>
blah blah <?php
method since it's a bit easier. i just don't know how to display it in the control panels echoing it out as selected, so i check to see if anything's checked in that section and if so update the entire thing. i'm trying to figure out something that i can do that checks them all at once or something instead of checking as i'm echoing it out

POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

Oh, checked as in examining, not checked as in selected?

I'm afraid I'll have to echo Mark here -- hunh?

They have: 461 posts

Joined: Jul 2003

making a new thread since this has two things and i think that's confusing ppl

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.