Echo problem when a different user logs in
i have been trying to change the output of my systems list or table page whenever a different user logins in.
i have 2 major users (admin and super admin) and minor users (company registered accounts). my admin use is to upload files sent by other company. the uploaded file is then passed to the other account "super admin". the super admin is used to approve or disapprove uploaded files submitted by the admin.this files originally came from the other company. the table is already ordered by employee name,status and title. and i already inserted the condition that it should echo the name and id once.
This is the condition before
when the admin logs in, the table in the home will output all the uploaded files whatever its status may be.this also applies to super admin. while in the other company, only the files uploaded by the employee in that company may be seen or is outputted. all of this code is working properly.
This is the condition i am expecting to have now
when the admin logs in, the table in the home will output all the uploaded files whatever its status may be. when the super admin logs in, the homepage table will output only files with the status approved and not approved. uploaded file with a pending status must echo in the other page that i entitled "New Uploads" that i'm working to do now. And when other users log in, they will only see the files with the approved or not approved status.
i hope somehow i made it clear. :( i have been trying to solve this problem for 2 days now but wrong outputs always appear,so i would like to ask for you help :(
this is what the output table looks like in my system
if the admin page is login *EmployeeID* *EmployeeName* *Title* *FileDate* *Status* *Confirmation* 20864125 Keisha file2 Feb 01, 2000 Pending Delete 20080407 Mariel file5 Aug 01, 2000 Pending Delete file1 Jan 01, 2000 Pending Delete 16521253 Riorei file13 Jan 01, 2000 Pending Delete file10 Mar 20, 2003 Pending Delete if the super admin login *EmployeeID* *EmployeeName* *Title* *FileDate* *Status* *Confirmation* 20864125 Keisha file2 Feb 01, 2000 Pending Approve/Not Approve 20080407 Mariel file5 Aug 01, 2000 Pending Approve/Not Approve file1 Jan 01, 2000 Pending Approve/Not Approve 16521253 Riorei file13 Jan 01, 2000 Pending Approve/Not Approve file10 Mar 20, 2003 Pending Approve/Not Approve an if other user log in *EmployeeID* *EmployeeName* *Title* *FileDate* *Status* 20864125 Keisha file2 Feb 01, 2000 Pending
now that you see the difference,i would like to apply the new condition in that output :( this is the code i used
while ($row = mysql_fetch_assoc($query))
{
$file_id = $row['file_id'];
$file_desc = $row['file_description'];
$file_date = $row['file_date'];
$file_name = $row['file_name'];
$file_accs = $row['folder_access'];
$file_employee = $row['employee_id'];
$file_confir = $row['confirmation'];
$file_ename = ucwords($row['employee_name']);
$emp_id=$emp_id==$row['employee_id']?"":$row['employee_id'];
$emp_name=$emp_name==$row['employee_name']?"":$row['employee_name'];
$info = pathinfo($file_name);
$file_ext = $info['extension'];
echo '<tr>
<td>
</td>
</tr>
<tr class="subone">
<td class="sub" width="100">
'.$emp_id.'
<br />
</td>';
if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'sa')
{
?><td class="sub" width="100">
<a href="" onclick = javascript:newPopup('addfile.php?emp=<?php echo $file_employee ?>');><?php echo$emp_name?></a>
<br />
</td><?php
}
else
{
echo '<td class="sub" width="182">
'.$emp_name.'
<br />
</td>';
}
echo'<td class="sub" width="218">
<a href="'.$file_accs.$file_name.'" target="_blank" style="text-decoration: underline;">'.$file_desc.'</a>
<br />
</td>
<td class="sub" width="100">
'.date('M d, Y',mktime(0,0,0,substr($file_date,5,2),substr($file_date,8,2),substr($file_date,0,4))).'
<br />
</td>
<td class="sub" width="100">
'.$file_confir.'
<br />
</td>';
开发者_如何学Go if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'sa')
{
if($file_confir == 'Pending' OR $file_confir == 'NotApproved')
{
if(isset($_GET['id']))
{
$fgmembersite->Delete_Db($_GET['id']);
}
echo '<td class="sub" width="100">
<a href="index.php?id='.$file_id.'">Delete</a>
<br />
</td>';
}
}
else if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'admin')
{
if($file_confir == 'Pending')
{
if(isset($_GET['yes']))
{
$fgmembersite->UpdateYesDB($_GET['yes']);
//echo "<script>location.reload();</script>";
}
else if(isset($_GET['no']))
{
$fgmembersite->UpdateNoDB($_GET['no']);
//echo "<script>location.reload();</script>";
}
if (!isset($_GET['offset'])) {
$prevoffset = 0;
} else {
$prevoffset = $_GET['offset'];
}
echo'<td class="sub" width="100">
<a href="index.php?offset='.$prevoffset.'&searchfile='.$search.'&namelist='.$listname.'&yes='.$file_id.'">Approve</a>
<br /><br />
<a href="index.php?offset='.$prevoffset.'&searchfile='.$search.'&namelist='.$listname.'&no='.$file_id.'">NotApprove</a>
</td> ';
}
}
}?>
this works properly when the new condition is not yet applied.now my problem is how could i apply the new condition here? i have tried using this set of code:
if($_SESSION[$fgmembersite->GetLoginSessionVar()] != 'sa' && $file_confir == '' OR $file_confir == 'NotApproved')
before the echo statement. but it produced the wrong output, can someone tell me what should i do here? :( i know i should use condition statements to do this,but i don't know which one will fit. thanks for those who would reply.
Your if/ elseif statement checks for admin and superadmin already, wouldn't the regular user just be in the else?
if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'sa'){
// your code here
} elseif($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'admin') {
// more code here
} else {
// here goes the code of your regular user
if($file_confir == '' OR $file_confir == 'NotApproved'){
// display the file
}
}
As a side note: You might find it a lot easier to write code / debug if you wouldn't mix HTML and PHP. The code formatting /indents are also not consistent, but that may be due to copy/paste
精彩评论