Re: [PHP] A php-mysql checkbox question

2003-07-05 Thread Lowell Allen
 From: John T. Beresford [EMAIL PROTECTED]
 
 I have a problem trying to show a checkbox list and have some of the
 boxes checked and not others. Here are the details:
 
 table: features
 rec_id  |  fName
 -
 1   |  Window
 -
 2   |  pool
 -
 3   | fence
 -
 4   | Drive
 
 
 table: com_features
 
 rec_id  |  com_features_id  |  feature_id
 --
 1   |  2|  1
 --
 2   |  1|  4
 --
 3   |  1|  3
 --
 4   |  2|  3
 --
 5   |  4|  4
 --
 6   |  7|  4
 --
 7   |  8|  4
 --
 8   |  2|  4
 
 
 
 what I want is to display a checkbox list that would show all the
 values from 'features' and have the appropriate boxes checked when
 'com_features.com_features.id = 2'
 
 ie
 
 X  Window
 pool
 X  fence
 X  drive
 
 The query I am using now is:
 
 $sql =SELECT
 features.rec_id AS rec_id,
 features.fName AS fName,
 com_features.feature_id AS feature_id,
 com_features.com_rec_id AS com_rec_id
 FROM features, com_features
 WHERE com_features.com_rec_id = \2\ AND features.TheTest=\1\;
 
 What I get in the return is:
 
 X  Window
 pool
 fence
 drive
 
 Window
 pool
 X  fence
 drive
 
 Window
 pool
 fence
 X  drive

I'm not sure how you're formatting (HTML?), what TheTest is, or what this
has to do with PHP, but how about this select statement:

$sql = SELECT features.fName, features.rec_id
FROM features, com_features
WHERE features.rec_id = com_features.feature_id
AND com_features.com_features_id = '2';

HTH

--
Lowell Allen



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] A php-mysql checkbox question

2003-07-04 Thread John T. Beresford
Hello,

I have a problem trying to show a checkbox list and have some of the 
boxes checked and not others. Here are the details:

table: features
rec_id  |  fName
-
1   |  Window
-
2   |  pool
-
3   | fence
-
4   | Drive
table: com_features

rec_id  |  com_features_id  |  feature_id
--
1   |  2|  1
--
2   |  1|  4
--
3   |  1|  3
--
4   |  2|  3
--
5   |  4|  4
--
6   |  7|  4
--
7   |  8|  4
--
8   |  2|  4


what I want is to display a checkbox list that would show all the 
values from 'features' and have the appropriate boxes checked when 
'com_features.com_features.id = 2'

ie

X  Window
   pool
X  fence
X  drive
The query I am using now is:

$sql =SELECT
features.rec_id AS rec_id,
features.fName AS fName,
com_features.feature_id AS feature_id,
com_features.com_rec_id AS com_rec_id
FROM features, com_features
WHERE com_features.com_rec_id = \2\ AND features.TheTest=\1\;
What I get in the return is:

X  Window
   pool
   fence
   drive
   Window
   pool
X  fence
   drive
   Window
   pool
   fence
X  drive
TIA for any help,
John
--
===
John T. Beresford, Owner
Digital Studio Design
Edmond, OK
http://www.digitalstudiodesign.com/
405.760.0794
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php