Jump to content


Photo

Different views for users groups


  • Please log in to reply
10 replies to this topic

#1 azziman

azziman
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 08 October 2006 - 11:00 AM

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 student
Whereas the lecturers have  limited access to the student personal details, like certain fields are hidden / removed

any help will be appreciated as always  ;D

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 08 October 2006 - 11:46 AM

Pseudo code example....

if ($_SESSION['grp'] == 'admin') {
  echo "this is for admins only";
}


#3 azziman

azziman
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 08 October 2006 - 11:54 AM

ummm, oki i dont think what i wrote prior was very clear *silly me*

here is a small extract from some code im using

<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>

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.

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 08 October 2006 - 02:14 PM

if the student id is in a session then this should work will show the admin the id of the student anyone else nothink.


<?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>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 azziman

azziman
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 08 October 2006 - 02:17 PM

thanx red arrow i will give it a shot :D

#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 08 October 2006 - 02:24 PM

ok i edited the code ok have a look.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#7 azziman

azziman
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 08 October 2006 - 02:57 PM

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:

$query="select * from admin where admin_id='$admin_id'";

I read on the JOIN syntax but i dont think that is what i would need for this one.



#8 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 08 October 2006 - 02:59 PM

post your database then we all can see ok becouse my magic balls not working.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#9 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 08 October 2006 - 03:06 PM


I dont know joins but you can try this ok.



<?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>


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#10 azziman

azziman
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 08 October 2006 - 03:13 PM

-- --------------------------------------------------------

-- 
-- 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');


oki thats the database, and yup your solution does work :D

#11 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 08 October 2006 - 03:15 PM

good we done it then yep.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users