azziman Posted October 8, 2006 Share Posted October 8, 2006 Hi there,how would i be able to make different views of the information for user groups. For example:The admin group will have full acess to the personal details of a studentWhereas the lecturers have limited access to the student personal details, like certain fields are hidden / removedany help will be appreciated as always ;D Quote Link to comment https://forums.phpfreaks.com/topic/23343-different-views-for-users-groups/ Share on other sites More sharing options...
trq Posted October 8, 2006 Share Posted October 8, 2006 Pseudo code example....[code=php:0]if ($_SESSION['grp'] == 'admin') { echo "this is for admins only";}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/23343-different-views-for-users-groups/#findComment-105810 Share on other sites More sharing options...
azziman Posted October 8, 2006 Author Share Posted October 8, 2006 ummm, oki i dont think what i wrote prior was very clear *silly me*here is a small extract from some code im using[code]<table width="550" border="0"> <tr class="main"> <td colspan="3" class="main">Student ID</td> <td colspan="3" class="main"><?php echo "$student_id" ?></td> </tr> <tr class="main"> <td colspan="3" class="main">School Year</td> <td colspan="3"><select name="edit14" size="1" id="select2"> <option value="">--Select--</option> <option value="7" <?php if ($student_year == '7'){ echo "selected"; } ?>>7</option> <option value="8" <?php if ($student_year == '8'){ echo "selected"; } ?>>8</option> <option value="9" <?php if ($student_year == '9'){ echo "selected"; } ?>>9</option> <option value="10" <?php if ($student_year == '10'){ echo "selected"; } ?>>10</option> <option value="11" <?php if ($student_year == '11'){ echo "selected"; } ?>>11</option> <option value="Unassigned" <?php if ($student_year == 'unassigned'){ echo "selected"; } ?>>unassigned</option> </select></td> </tr> <tr class="main"> <td colspan="3" class="main">Forename:</td> <td colspan="3"><input type="text" name="edit" value='<?php echo "$student_forename" ?>' /></td> </tr> <tr class="main"> <td colspan="3" class="main">Surname:</td> <td colspan="3"><input type="text" name="edit1" value='<?php echo "$student_surname" ?>' /></td> </tr></table>[/code]Now if i wanted to hide the student ID from all other users except the admin, is that possible without making new pages that are specific to that user group only. Quote Link to comment https://forums.phpfreaks.com/topic/23343-different-views-for-users-groups/#findComment-105812 Share on other sites More sharing options...
redarrow Posted October 8, 2006 Share Posted October 8, 2006 if the student id is in a session then this should work will show the admin the id of the student anyone else nothink.[code]<?php session_start();//database information$query="select * from admin where admin_id='$admin_id'";$result=mysql_query($query);if(mysql_num_rows($result)==1){?><table width="550" border="0"> <tr class="main"> <td colspan="3" class="main">Student ID</td> <td colspan="3" class="main"><?php echo $student_id}else{ }; ?></td> </tr> <tr class="main"> <td colspan="3" class="main">School Year</td> <td colspan="3"><select name="edit14" size="1" id="select2"> <option value="">--Select--</option> <option value="7" <?php if ($student_year == '7'){ echo "selected"; } ?>>7</option> <option value="8" <?php if ($student_year == '8'){ echo "selected"; } ?>>8</option> <option value="9" <?php if ($student_year == '9'){ echo "selected"; } ?>>9</option> <option value="10" <?php if ($student_year == '10'){ echo "selected"; } ?>>10</option> <option value="11" <?php if ($student_year == '11'){ echo "selected"; } ?>>11</option> <option value="Unassigned" <?php if ($student_year == 'unassigned'){ echo "selected"; } ?>>unassigned</option> </select></td> </tr> <tr class="main"> <td colspan="3" class="main">Forename:</td> <td colspan="3"><input type="text" name="edit" value='<?php echo "$student_forename" ?>' /></td> </tr> <tr class="main"> <td colspan="3" class="main">Surname:</td> <td colspan="3"><input type="text" name="edit1" value='<?php echo "$student_surname" ?>' /></td> </tr></table>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/23343-different-views-for-users-groups/#findComment-105849 Share on other sites More sharing options...
azziman Posted October 8, 2006 Author Share Posted October 8, 2006 thanx red arrow i will give it a shot :D Quote Link to comment https://forums.phpfreaks.com/topic/23343-different-views-for-users-groups/#findComment-105850 Share on other sites More sharing options...
redarrow Posted October 8, 2006 Share Posted October 8, 2006 ok i edited the code ok have a look. Quote Link to comment https://forums.phpfreaks.com/topic/23343-different-views-for-users-groups/#findComment-105853 Share on other sites More sharing options...
azziman Posted October 8, 2006 Author Share Posted October 8, 2006 oki i understand what your code is doing, if the admin is not logged in then do not show the student id. What im trying to do is now add the lecturer login table to the select statement: [code] $query="select * from admin where admin_id='$admin_id'";[/code]I read on the JOIN syntax but i dont think that is what i would need for this one. Quote Link to comment https://forums.phpfreaks.com/topic/23343-different-views-for-users-groups/#findComment-105869 Share on other sites More sharing options...
redarrow Posted October 8, 2006 Share Posted October 8, 2006 post your database then we all can see ok becouse my magic balls not working. Quote Link to comment https://forums.phpfreaks.com/topic/23343-different-views-for-users-groups/#findComment-105870 Share on other sites More sharing options...
redarrow Posted October 8, 2006 Share Posted October 8, 2006 I dont know joins but you can try this ok.[code]<?php session_start();//database information$query1="select * from lec where lec_id='$lec_id'";$result1=mysql_query($query1);if(mysql_num_rows($result1)==1){$query2="select * from admin where admin_id='$admin_id'";$result2=mysql_query($query2);if(mysql_num_rows($result2)==1){?><table width="550" border="0"> <tr class="main"> <td colspan="3" class="main">Student ID</td> <td colspan="3" class="main"><?php echo $student_id}}else{ }; ?></td> </tr> <tr class="main"> <td colspan="3" class="main">School Year</td> <td colspan="3"><select name="edit14" size="1" id="select2"> <option value="">--Select--</option> <option value="7" <?php if ($student_year == '7'){ echo "selected"; } ?>>7</option> <option value="8" <?php if ($student_year == '8'){ echo "selected"; } ?>>8</option> <option value="9" <?php if ($student_year == '9'){ echo "selected"; } ?>>9</option> <option value="10" <?php if ($student_year == '10'){ echo "selected"; } ?>>10</option> <option value="11" <?php if ($student_year == '11'){ echo "selected"; } ?>>11</option> <option value="Unassigned" <?php if ($student_year == 'unassigned'){ echo "selected"; } ?>>unassigned</option> </select></td> </tr> <tr class="main"> <td colspan="3" class="main">Forename:</td> <td colspan="3"><input type="text" name="edit" value='<?php echo "$student_forename" ?>' /></td> </tr> <tr class="main"> <td colspan="3" class="main">Surname:</td> <td colspan="3"><input type="text" name="edit1" value='<?php echo "$student_surname" ?>' /></td> </tr></table>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/23343-different-views-for-users-groups/#findComment-105873 Share on other sites More sharing options...
azziman Posted October 8, 2006 Author Share Posted October 8, 2006 [code]-- ---------------------------------------------------------- -- Table structure for table `admin`-- CREATE TABLE `admin` ( `admin_id` int(25) NOT NULL auto_increment, `username` varchar(25) NOT NULL default '', `password` varchar(100) NOT NULL default '', `email_address` varchar(250) NOT NULL default '', PRIMARY KEY (`admin_id`)) TYPE=MyISAM COMMENT='Admin Users' AUTO_INCREMENT=4 ;-- -- Dumping data for table `admin`-- INSERT INTO `admin` VALUES (1, 'admin1', 'c56594001e03e8ccb5870e0e2df5c0e7', 'azziman@hotmail.com');INSERT INTO `admin` VALUES (2, 'admin2', 'cbb2d5a9b5e6e8421452bbbdfd01034f', 'azziman0@hotmail.com');-- ---------------------------------------------------------- -- Table structure for table `lecturer`-- CREATE TABLE `lecturer` ( `lecturer_id` int(25) NOT NULL auto_increment, `username` varchar(25) NOT NULL default '', `password` varchar(100) NOT NULL default '', `email_address` varchar(250) NOT NULL default '', PRIMARY KEY (`lecturer_id`)) TYPE=MyISAM COMMENT='Lecturer Users' AUTO_INCREMENT=4 ;-- -- Dumping data for table `lecturer`-- INSERT INTO `lecturer` VALUES (1, 'lect1', 'dsfsafsgsgsgre4534536546yy5454gh', 'azziman1@hotmail.com');INSERT INTO `lecturer` VALUES (2, 'lect2', 'dfhsky76764krhg43br43r43y88703hn', 'azziman2@hotmail.com');[/code]oki thats the database, and yup your solution does work :D Quote Link to comment https://forums.phpfreaks.com/topic/23343-different-views-for-users-groups/#findComment-105877 Share on other sites More sharing options...
redarrow Posted October 8, 2006 Share Posted October 8, 2006 good we done it then yep. Quote Link to comment https://forums.phpfreaks.com/topic/23343-different-views-for-users-groups/#findComment-105879 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.