Can't keep checkbox value using array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jbstone713
Forum Newbie
Posts: 14
Joined: Wed Mar 02, 2005 10:01 pm

Can't keep checkbox value using array

Post 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]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

name them move[$value]

check agsinst $move[$value]


turn off register_globals..
jbstone713
Forum Newbie
Posts: 14
Joined: Wed Mar 02, 2005 10:01 pm

Thank You

Post 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!
Post Reply