Page 1 of 1

Can't keep checkbox value using array

Posted: Wed Mar 02, 2005 10:13 pm
by jbstone713
Someone please help. I am trying to keep the value of checkboxes(keep them checked if they are checked) if the user makes a mistake and has to re-do the form. I need to use an array to store my checkbox values. Here is a code example. Please help or modify. I've been at this for 2 days!!!

Code: Select all

<?php 
print ("<BR>"); 
print ("<BR>"); 
foreach ($move as $value1) { 
echo "Value: $value1<br />\n"; 
} 
$arr = array('car', 'bike'); 
print("<form name=input action=?php_self method=get>"); 
reset($arr); 

while (list(, $value) = each($arr)) { 

print("I have a $value:"); 
print ("<input type=checkbox name="moveї]" value="$value""); 

if($moveїvalue] == $arrїvalue]){ 

print ("CHECKED"); 
} 
print (">"); 


print ("<BR>"); 
print ("$value1--$value"); 

print ("<BR>"); 
print ("<BR>"); 
} 
print("<input type=submit value=Submit>"); 
print("</form>"); 

?>
Thanks,

A person in need


feyd | please use

Code: Select all

while

Code: Select all

tags are offline[/color]

Posted: Wed Mar 02, 2005 10:47 pm
by feyd
name them move[$value]

check agsinst $move[$value]


turn off register_globals..

Thank You

Posted: Thu Mar 03, 2005 8:31 am
by jbstone713
Thank you soooooo much. You helped me a lot. Sorry about double posting, this is my first time here (I'm a newbie!) Won't happen again. Thanks again!