php-mysql

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
msvasu
Forum Newbie
Posts: 2
Joined: Thu Nov 25, 2010 12:46 am

php-mysql

Post 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
tutigan
Forum Newbie
Posts: 18
Joined: Thu Oct 28, 2010 5:43 am

Re: php-mysql

Post 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!
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: php-mysql

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