Page 1 of 1

php-mysql

Posted: Thu Nov 25, 2010 12:51 am
by msvasu
I have table called products, i have two fields pro_id, name.
Now I got all the data from this table into table format and now i want to add a chexbox in the last column of every rows, when i select the check box and click on submit.
my output should be in another php file where i shoule get all the contnet which i checked in the table format
--------------------------
pro id Name checked
--------------------------
1 abc yes
2 xyz no
3 mno yes

my output should be

--------------------------
pro id Name checked
--------------------------
1 abc yes
3 mno yes

please help

Re: php-mysql

Posted: Thu Nov 25, 2010 1:09 am
by tutigan
hi msvasu,

not entirely sure what it is you are trying to do... could you perhaps share the code that you are having trouble with?
from what I gather, what you want to do is change your MySQL query to something like:

Code: Select all

$query = "SELECT * FROM products WHERE checked = 'yes'";
if that helps, great! if not, please elaborate!

Re: php-mysql

Posted: Thu Nov 25, 2010 1:16 pm
by Celauran
If I'm understanding you right, an easy solution would be to use an array inside the form. Example:

Code: Select all

<input type="checkbox" name="proid[]" value="<?php echo $row['pro_id']; ?>" />
The form's action goes to the other page you mentioned, where you can just loop through $_POST['proid'] and do whatever you need to do.