I don’t know how to rewrite questions, so I’ll just contact my old post here, some element will not echo after putting some condition in php
although some problems were solved there thanks to @Shinkou, there are still errors in my program. I tried to find out what caused this problem, but I did not find any luck in solving them.
Now let me tell you what my program does. I have 2 administrators with various functions. The administrator downloads the file and registers new information about the company and the employee. He is also responsible for deleting unapproved or pending files. (NO PROBLEMS HERE ^ _ ^), the second is a super-admin. its purpose is to view the downloaded files and approve or reject the downloaded file. (AS YOU SEE, ITS ALL ABOUT FILES FILLED BY THE ADMINISTRATOR), the other user is the company account. This account is created when an administrator registers a new company. Its purpose is simply to see which file was approved or rejected by the supermin.
my problem is everything in the super admin and another user.but, let's talk about super admin. more.my superadmin contains 3 menubars (I used link images here) → HOME ( to view all accepted / rejected files ), NEW UPLOAD ( to view and accept / reject all pending files ) and LOGOUT. NO NEW WORKS and LOGOUT work, but I am having problems with the home resource, and this affects other user accounts. Lastly, the code format is something like this.let show me:
* EmployeeID * * EmployeeName * * Title * * FileDate * * Status *
20132248 Danica file8 Jan 08, 2001 Approved
20896647 Jan file7 Dec 12, 2000 NotApproved
20864125 Keisha file2 Feb 01, 2000 Approved
16521253 Riorei file10 Mar 20, 2003 NotApproved
file3 Jul 14, 2002 Approved
// if you could notice employee riorei, it contains 2 files, the employeename and id will be displayed only once. this one is also already sorted as you could notice i wish.
let me list all the problems I encountered and the things that I discovered when I track the problem:
- echo problem → example if riorei has 2 uploaded files, file10 and file3, if you want to accept / reject the first file10 / file3 in newupload, the name and identifier did not appear in my output ( this is what I did: I tried to repeat The 2 variables that I used ($ empid and $ file_employee for id and $ empname and $ file_ename for name). $ Empname and $ empid are first initialized to "" (i will show you the codes later) next to emmployeeid (first I tried it with identifier), and this is the result I found ==> $ empid, which should contain a null value that already contains the identifier employeeID, at the beginning, which should indicate that after the next loop.) BUT , if you want to accept the next file .its ok>. <but I can't just leave it like this right?
- Another thing that I noticed is that there are some uploaded / registered files that overlap in the first loop with the name and id.its, like some uploaded files, the echo is correct, and some are not.
- Limit LIMIT-> I'm in my table, which I meant, on the page (yes, I also created the page number), only 5 files are issued. BUT on my page 1 it contains only 3 files, then the next page contains 1 file, etc. In addition, even at some point there was something similar to the next page, there were no files uploaded, but if you click again again, Tada! the file is. ( this is what I did: I set the counter to check how many times it went in cycles in my while article. shocked.it says 5 to my! and I don’t know how this happens.)
as far as i noticed, this is the only error i found. so let me show you the codes i used :)
<?php $search = '%'; $fgmembersite->DBLogin(); $limit = 5; if(isset($_GET['offset'])) { $offset = mysql_real_escape_string($_GET['offset']); } else { $offset = 0; } //for namelist az $listname = '%'; If (isset($_GET['namelist'])) { $listname = $_GET['namelist']; } //for search file if(isset($_POST['searchfile'])) { $search = $_POST['searchfile']; } else if(isset($_GET['searchfile'])) { $search = $_GET['searchfile']; } if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'sa' OR $_SESSION[$fgmembersite->GetLoginSessionVar()] == 'admin') { //$sql="select * from gmdc_employee where employee_name like '%$search%' AND employee_name like '$listname%' "; $sql="SELECT `e`.* FROM `gmdc_employee` `e` JOIN `gmdc_user` `u` ON ( `u`.`company_id` = `e`.`company_id` ) WHERE (`u`.`company_name` LIKE '%$search%' OR `e`.`employee_name` LIKE '%$search%' OR `e`.`employee_id` LIKE '%$search%') AND `e`.`employee_name` LIKE '$listname%' "; } else { $sql = "select `e`.* from `gmdc_user` `u`, `gmdc_employee` `e` where `u`.`username` = '".$_SESSION[$fgmembersite->GetLoginSessionVar()]."' and `u`.`company_id` = `e`.`company_id` AND `e`.`employee_name` like '$listname%' AND `e`.`employee_name` like '%$search%'"; } $query = mysql_query("$sql ORDER BY `e`.`employee_name`, `e`.`confirmation` DESC ,`e`.`file_id` DESC,`e`.`file_date` DESC LIMIT $offset,$limit") or die ( mysql_error () ); $result = mysql_query($sql) or die (mysql_error()); $total = mysql_num_rows($result); $emp_id = ''; //This will be use to remove employee_id if its already echoed. $emp_name = ''; //This will be use to remove employee_name if its already echoed. $count = 0; if(!$result || mysql_num_rows($result) <= 0) { $fgmembersite->HandleError("No file found."); return false; } 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']; $count = $count + 1; echo $count; if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'sa') { echo '<tr> <td> </td> </tr> <tr class="subone"> <td class="sub" width="100"> '; if ($file_employee == $emp_id) {
Sorry if it is too long, it just needs some to require or ask for the complete codes that I used, although this is only part. I hope someone can help me here. :(