halm1985 Posted May 29, 2007 Share Posted May 29, 2007 Again the students grades project .. The scores table has an attribute named "APPROVED" which data type is boolean (true/false) Can someone give me an idea on how to make grades data viewable ONLY IF the value on this column is set to TRUE Another question ? what is the datatype in MySQL equivalent to (true/false) in Access ( note : i'm using PHPMyAdmin ) and how true and false values are represented ? Link to comment https://forums.phpfreaks.com/topic/53436-solved-viewing-data-based-on-attribute-value/ Share on other sites More sharing options...
emehrkay Posted May 29, 2007 Share Posted May 29, 2007 SELECT fields FROM table WHERE APPROVED = 1 Link to comment https://forums.phpfreaks.com/topic/53436-solved-viewing-data-based-on-attribute-value/#findComment-264044 Share on other sites More sharing options...
taith Posted May 29, 2007 Share Posted May 29, 2007 if($val===true){ echo 'show data'; } if you have a varchar(5) or an int(1) you can either store bool as true/false, or 1/0 Link to comment https://forums.phpfreaks.com/topic/53436-solved-viewing-data-based-on-attribute-value/#findComment-264046 Share on other sites More sharing options...
per1os Posted May 29, 2007 Share Posted May 29, 2007 I would use an TINYINT(1) if the column value is 1 show them if it is 0 do not show them. Link to comment https://forums.phpfreaks.com/topic/53436-solved-viewing-data-based-on-attribute-value/#findComment-264049 Share on other sites More sharing options...
redarrow Posted May 29, 2007 Share Posted May 29, 2007 The best way i recon to acheve this is useing the ENUM in the database 0 or 1 meaning the value must be 0 or 1 from the entry. Link to comment https://forums.phpfreaks.com/topic/53436-solved-viewing-data-based-on-attribute-value/#findComment-264057 Share on other sites More sharing options...
halm1985 Posted May 29, 2007 Author Share Posted May 29, 2007 This solves part of the problem but not all .. Maybe i should explain in more details .. Each student has a number of records in the scores table for (score for each subject ) .. two columns are there : one for MID-Term Score, and the second is for Final Score ... Mid-term scores are viewable without approval .. however, Final Scores are not . again the two values are in one row .. Now the scenario should be as follows : A student logs to his page ... a table is there that contains the scores for each subject, MID-TERM Scores are viewable once their are filled into the Database .. However, FINAL SCORES are not viewable ( even if they exist ) unless the column ( Approved ) value is set to true .. How to do that in PHP ? Attached is a sample of the data structure [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/53436-solved-viewing-data-based-on-attribute-value/#findComment-264066 Share on other sites More sharing options...
redarrow Posted May 29, 2007 Share Posted May 29, 2007 use a int and defult as 0 as unaproved then update the database when it is aproved get me so if the number is 1 then show total ok Link to comment https://forums.phpfreaks.com/topic/53436-solved-viewing-data-based-on-attribute-value/#findComment-264094 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.