Jump to content

List all but echo in checkbox only selected


web_master

Recommended Posts

Hi,

 

got a little problem.

 

There is a 3 table:

 

I want to list all the product groups but to be checked in checkbox only what choose the user.

 

If from outside (choos.php?tt_reg_id=1) user is nr 1 then in listed checkboxes need to be checked only those checkboxes what the user nr 1 choose / but listed the all product groups.

 

 

<form method="post" action="<?php $_SERVER['PHP_SELF'];?>">
<?php
/* There is 3 tables
1. table of PRODUCT GROUPS => tt_product_group
2. table of CHOOSSING => tt_reg_choice
and te 3. table is the table of USERS => tt_reg
*/

include "../mysql_connect.php";
error_reporting(E_ERROR);
@ini_set('display_errors', '1');

$query_product_group_check = mysql_query("Select
tt_product_group.tt_product_group_id,
tt_product_group.tt_product_group_sr,
tt_reg_choice.tt_reg_choice_id,
tt_reg_choice.tt_reg_choice_reg,
tt_reg_choice.tt_reg_choice_check,
tt_reg.tt_reg_id,
tt_reg.tt_reg_firm
From
tt_product_group
,
tt_reg_choice
Inner Join tt_reg ON tt_reg.tt_reg_id = tt_reg_choice.tt_reg_choice_reg
");

		if(!$query_product_group_check) {
			echo mysql_error();
			exit;
		}

		while($request = mysql_fetch_array($query_product_group_check)) {

		if(isset($request['tt_reg_choice_check'])) {
			$checked_ornot = "checked";
		} else {
			$checked_ornot = "";
		}
?>
<input type="checkbox" name="tt_reg_choice_check[<?php print $request['tt_product_group_id'];?>]" value="<?php print $request['tt_product_group_id'];?>" <?php print $checked_ornot;?>><?php print $request['tt_product_group_sr'];?>
<input type="hidden" name="tt_reg_id" value="<?php $_REQUEST['tt_reg_id'];?>">
<?php }?>
<form>

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.