Hello,
I need some help in retrieve and display data from MySQL table where, I had a table name “employees ”
contents :
---------------------------------------------------------
id|emp_name|rep ort_to
---------------------------------------------------------
01|Scott|00
02|John|01
03|Martin|01
04|Smith|02
05|Sam|00
06|Henry|02
---------------------------------------------------------
"00" report_to should be report direct/null.
One more thing is it possible to display the ID with leading zero.
If I want to see the "01" the display should be.
---------------------------------------------------------
MID|Manager|TLI D|TeamLeader|Em pID|Employees
---------------------------------------------------------
01|Scott|02}Joh n|04|Smith
01|Scott|02|Joh n|06|Henry
01|Scott|03|Mar tin|--|------
If I want to see the "02" the display should be.
---------------------------------------------------------
TLID|TeamLeader |EmpID|Employee s
---------------------------------------------------------
02|John|04|Smit h
02|John|06|Henr y
---------------------------------------------------------
I am using this code in php :
Hope to meet some expert here
Any help will be appreciated.
Thanks in advance
I need some help in retrieve and display data from MySQL table where, I had a table name “employees ”
contents :
---------------------------------------------------------
id|emp_name|rep ort_to
---------------------------------------------------------
01|Scott|00
02|John|01
03|Martin|01
04|Smith|02
05|Sam|00
06|Henry|02
---------------------------------------------------------
"00" report_to should be report direct/null.
One more thing is it possible to display the ID with leading zero.
If I want to see the "01" the display should be.
---------------------------------------------------------
MID|Manager|TLI D|TeamLeader|Em pID|Employees
---------------------------------------------------------
01|Scott|02}Joh n|04|Smith
01|Scott|02|Joh n|06|Henry
01|Scott|03|Mar tin|--|------
If I want to see the "02" the display should be.
---------------------------------------------------------
TLID|TeamLeader |EmpID|Employee s
---------------------------------------------------------
02|John|04|Smit h
02|John|06|Henr y
---------------------------------------------------------
I am using this code in php :
Code:
PHP CODE : $sql="select t1.id, t1.emp_name from employees as t1 where report_to='$_POST[text]' "; $data=mysql_query($sql) or die(mysql_error()); echo "<table border='2'>"; while ($rec=mysql_fetch_row($data)) echo "<tr><td>$rec[0]</td><td>$rec[1]</td></tr>"; echo " </table>"; ?> <br /> <form method="post" action=""> Username:<input type="text" name="text" /> <input type="submit" value="Submit" /> </form>
Any help will be appreciated.
Thanks in advance
Comment