PHP Programming

AdamSnow

Diamond Member
Nov 21, 2002
5,736
0
76
Hey everyone!
I have a PHP programming question... now I'm sure this is very very basic, but I just don't know how to move forward with what I want to do... I'm sure there are a bunch of ways to do it as well - I just don't know enough about it...

First, have a look at the form I am using...
PHP Form

Okay... what I want to happen here, is I'm going to have a dozen or so "items" listed... When printing off a re-cap of what I did, I don't want to have everything printed on the next page...

I only want the items that I have "checked" to be passed to the next page for the printing of what I have done...

So basically, I have 20 things listed, but I only perform 2... I want to check those 2 boxes, fill out the data required and hit submit... on the next page, it would only show (for example)

Data Recovery 10 100
System Cleaning 1 100

Instead of showing this :

Virus Removal 0 0
Install Software 0 0
Data Recovery 10 100
Install Hardware 0 0
System Cleaning 1 100
Spyware Removal 0 0
etc...

Can anyone provide me some insight on what I should to do accomplish this? I was thinking that a bunch of IF statements would work...

IF checkbox1 = checked then print textbox1, textbox2, textbox3... but I'm not sure how to do that either...

Any help?

Thanks so much!
 

stndn

Golden Member
Mar 10, 2001
1,886
0
0
You can do what you're thinking.

if (isset ($_POST['checkbox1']))
{
// do something, like print the checkbox and label again in page 2
}
if (isset ($_POST['checkbox2']))
{
// do something else similar to above
}
// ... etc


Whatever you checked in page 1 will be set when you submit it. So, to check which one was checked, you can use isset() function.


Another thing which can make your life easier is, instead of naming the checkboxes different names, you would name them as array

<input type="checkbox" name="cb[]" value="one" /> one
<input type="checkbox" name="cb[]" value="two" /> two
<input type="checkbox" name="cb[]" value="three" /> three
<!-- etc -->

And when you submit the form and have it processed by your PHP script, you can simply loop through the array and see which ones are set and which are not, via isset()

Whenever you see one that is set, print that out on next page. Else, skip it
 

AdamSnow

Diamond Member
Nov 21, 2002
5,736
0
76
stndn - You are a great person... :) Thank you so much for your help with that code... works perfectly!

-- Adam