hello,
i have to make an aplication with innodb tables and i have a problem.
i have 2 tables
table_1
id1
text1
table_2
id2
text2
code_id_1 (foreign key for table_1.id1) ON DELETE RESTRICT
i select the database and each row has a checkbox[]
the question is how could i disable checkboxes of the fileds that are used?
example
table_1
1 blabla
2 balal
3 jhsd
table_2
1 aaaaaaaa 1
2 ssssssss 3
3 dddddddd 1
! the table_1.id='2' is not used by other tables
so here is how should look table_1
----------------------------------------------
checbox | id1 | text1 |
----------------------------------------------
checbox disabled | 1 | blabla |
checbox | 2 | balbal |
checbox disabled | 3 | jhsd |
----------------------------------------------
I hope i made my self clear.
thx in advance for your help
disable checkbox
Moderator: General Moderators
Code: Select all
SELECT *,
IF(table_2.code_id_1, 'enabled', 'disabled') AS status
FROM table_1
LEFT OUTER JOIN table2 ON table_2.code_id_1=table1_1.id_1- Think Pink
- Forum Contributor
- Posts: 106
- Joined: Mon Aug 02, 2004 3:29 pm
Code: Select all
$query = "........."; // what i posted above
$rs = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_assoc($rs))
{
if ($row['status'] == 'enabled')
{
echo "<input type='...' name='...' value='...'/>;
}
else
{
echo "....";
}
}- Think Pink
- Forum Contributor
- Posts: 106
- Joined: Mon Aug 02, 2004 3:29 pm
Code: Select all
SELECT *, IF(table_2.code_id_1 is null,'','disabled') AS status FROM table_1LEFT OUTER JOIN table2 ON table_2.code_id_1=table1_1.id_1- Think Pink
- Forum Contributor
- Posts: 106
- Joined: Mon Aug 02, 2004 3:29 pm
me again
i got it
here is the corect querry
thx for your help
i got it
here is the corect querry
Code: Select all
SELECT DISTINCT table_1.*, IF(table_2.code_id_1 is null,'','disabled') AS status FROM table_1 LEFT OUTER JOIN table_2 ON table_2.code_id_1=table_1.id_1