web_master Posted June 17, 2007 Share Posted June 17, 2007 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> Quote Link to comment https://forums.phpfreaks.com/topic/55922-list-all-but-echo-in-checkbox-only-selected/ Share on other sites More sharing options...
sasa Posted June 17, 2007 Share Posted June 17, 2007 use 'LEFT JOIN' in your SQL Quote Link to comment https://forums.phpfreaks.com/topic/55922-list-all-but-echo-in-checkbox-only-selected/#findComment-276236 Share on other sites More sharing options...
web_master Posted June 17, 2007 Author Share Posted June 17, 2007 use 'LEFT JOIN' in your SQL The result is everything listed 2 times and every checkbox is checked... Quote Link to comment https://forums.phpfreaks.com/topic/55922-list-all-but-echo-in-checkbox-only-selected/#findComment-276252 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.