0

hi,
i wanna print the result in a table but i am failing to do so..

other query in my table are working but dont knw why this query is not displaying in the table

SELECT user_profile.user_id, user_profile.user_name, payroll.salary, payroll.hra, payroll.da, payroll.pf, payroll.nsa, payroll.ince, user_profile.desig, user_data.period, user_data.work_hours
FROM payroll, user_profile, user_data
WHERE user_profile.desig = payroll.desig and user_profile.user_id='a1' and user_data.user_id='a1'

a little help would be greate ful .. i ran this query on php my admin it is displaying the result ..

please guide me on how i can display this in my html table .

$sql="SELECT user_profile.user_id, user_profile.user_name, payroll.salary, payroll.hra, payroll.da, payroll.pf, payroll.nsa, payroll.ince, user_profile.desig, user_data.period, user_data.work_hours
FROM payroll, user_profile, user_data
WHERE user_profile.desig = payroll.desig and user_profile.user_id='a1' and user_data.user_id='a1'";

$dat=mysql_query($sql);

while($row=mysql_fetch_row($dat))
 {
  echo"<tr><td>".$row[user_profile.user_id]."</td>";
  echo"<td>".$row[$user_name]."</td>";
  echo"<td>".$row[salary]."</td>";
  echo"<td>".$row[hra]."</td>";
  echo"<td>".$row[da]."</td>";
  echo"<td>".$row[pf]."</td>";      
  echo"<td>".$row[nsa]."</td>";
  echo"<td>".$row[ince]."</td>"; 
  echo"<td>".$row[desig]."</td>";
  echo"<td>".$row[period]."</td></tr>";
	}

please help me :(

Edited by daneuchar: n/a

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by daneuchar
0
<?php
$sql="SELECT user_profile.user_id, user_profile.user_name, payroll.salary, payroll.hra, payroll.da, payroll.pf, payroll.nsa, payroll.ince, user_profile.desig, user_data.period, user_data.work_hours
FROM payroll, user_profile, user_data WHERE user_profile.desig = payroll.desig and user_profile.user_id='a1' and user_data.user_id='a1'";

$dat=mysql_query($sql);

echo "<center><h2>Report of work and salary for " .ucfirst($user_name). "</h2></center>";

?>

<TABLE align="center" BORDER="1" CELLSPACING="5" CELLPADDING="5" WIDTH="80%">
<tr align=center><td>Emp Id</td><td>Emp Name</td><td>Period</td><td>Work<br>hours</td><td>Salary</td></tr>
<?php
 while($row=mysql_fetch_row($dat))
 {
  echo"<tr><td>".$row[user_profile.user_id]."</td>";
  echo"<td>".$row[$user_name]."</td>";
  echo"<td>".$row[salary]."</td>";
  echo"<td>".$row[hra]."</td>";
  echo"<td>".$row[da]."</td>";
  echo"<td>".$row[pf]."</td>";      
  echo"<td>".$row[nsa]."</td>";
  echo"<td>".$row[ince]."</td>"; 
  echo"<td>".$row[desig]."</td>";
  echo"<td>".$row[period]."</td></tr>";
	}

?>
</table>

PLease help!!

Edited by daneuchar: n/a

0

Hi CHeck the following coe, you need to use alias names for the data to display

<?php
$sql="SELECT user_profile.user_id user_id, user_profile.user_name user_name, payroll.salary salary, payroll.hra hra, payroll.da da, payroll.pf pf, payroll.nsa nsa, payroll.ince ince, user_profile.desig desig, user_data.period period, user_data.work_hours work_hours
FROM payroll, user_profile, user_data WHERE user_profile.desig = payroll.desig and user_profile.user_id='a1' and user_data.user_id='a1'";

$dat=mysql_query($sql);

echo "<center><h2>Report of work and salary for " .ucfirst($user_name). "</h2></center>";

?>

<TABLE align="center" BORDER="1" CELLSPACING="5" CELLPADDING="5" WIDTH="80%">
<tr align=center><td>Emp Id</td><td>Emp Name</td><td>Period</td><td>Work<br>hours</td><td>Salary</td></tr>
<?php
 while($row=mysql_fetch_row($dat))
 {
  echo"<tr><td>".$row['user_id']."</td>";
  echo"<td>".$row['user_name']."</td>";
  echo"<td>".$row['salary']."</td>";
  echo"<td>".$row['hra']."</td>";
  echo"<td>".$row['da']."</td>";
  echo"<td>".$row['pf']."</td>";      
  echo"<td>".$row['nsa']."</td>";
  echo"<td>".$row['ince']."</td>"; 
  echo"<td>".$row['desig']."</td>";
  echo"<td>".$row['period']."</td></tr>";
	}

?>
</table>

Edited by saiprem: n/a

0

i just found out the answer dude... its just so simple !! i was so dumb its an array so used this code and it worked

while($row=mysql_fetch_row($result))
 {
  
  echo"<tr><td>".$row[0]."</td>";
  echo"<td>".$row[1]."</td>";
  echo"<td>".$row[2]."</td>";
  echo"<td>".$row[3]."</td>";
  echo"<td>".$row[4]."</td>";
  echo"<td>".$row[5]."</td>";      
  echo"<td>".$row[6]."</td>";
  echo"<td>".$row[7]."</td>"; 
  echo"<td>".$row[8]."</td>";
  echo"<td>".$row[9]."</td>";
  echo"<td>".$row[10]."</td></tr>";
	}

the code u gave didnt work. but thanks anyway for taking you time to reply for my post :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.