Jump to content

[SOLVED] need help finishing a script


Aonxe

Recommended Posts

I am writing a wordpress plugin that shows a list of items with check boxes next to them and there is captcha at the end of the form, if the captcha isn't valid then the form show's again with all the items checked / filled in and gives them another chance to fill the captcha.

 

The problem that I am having is how to get the previously checked checkboxes to remain checked when the page loads again. Right now I have almost got it figured out but it only check's the last box if there are multiple boxes checked.

 

		$output .= '<h3>Problem Selections</h3>';
	$myposts = get_posts('order=ASC&orderby=post_title&category='.get_option('pp_category'));
	$number=1; 
	foreach($myposts as $post) : 
		if(isset($_POST['pp_send_email'])) { 
			foreach($postatas as $n => $f) {
				if($f == get_permalink($post->ID)) { 
					$checked = ' checked="checked"';
				} else { 
					$checked = NULL; 
				} 
			}
		}
		$output .= '<input style="margin-bottom:5px;" name="post[]" type="checkbox"'.$checked.' value="'.get_permalink($post->ID).'" /><label for="post'.$number.'" style="margin-bottom:5px;"><a href="'.get_permalink($post->ID).'" title="View '.$post->post_title.'">'.$post->post_title.'</a></label><br />';  
		$number = $number + 1; 
	endforeach;       

 

The results of the array would look like this

 

Array ( [0] => http://localhost/aonxe/age-of-conan-the-fatality/ [1] => http://localhost/aonxe/first-impressions-age-of-conan/ [2] => http://localhost/aonxe/take-2-age-of-conan/ ) 

 

Here is an image that might help a little.

 

problem.jpg

 

Hope that I was clear enough.

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/132460-solved-need-help-finishing-a-script/
Share on other sites

Anyone have any ideas, I know what the problem is and I have spent a few hours googling to no avail. The problem is that only the last value of the array is being used to check.

 

The Array looks like this

 

0 => A

1 => D

2 => E

 

It thinks that 0 should have the value of E instead of A, if that makes any sense.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.