Jump to content

please hlp me populating the table


coolagniho

Recommended Posts

<?php

$con=mysql_connect("localhost","root","");

if(!$con)

{

die('could not connect' .mysql_error());

}

mysql_select_db("hrc_fault",$con);

$query = "SELECT * " .

"FROM fault_book";

$result = mysql_query($query, $con)

or die(mysql_error());

$num_movies = mysql_num_rows($result);

$registered_comp=<<<EOD

<h2><center>Registered Fault HRC</center></h2>

<table width="70%" border="1" cellpadding="2"

cellspacing="2" align="center">

<tr>

<th>Job Cd No</th>

<th>Date</th>

<th>Section</th>

<th>Item Description</th>

<th>Item Sl.No</th>

<th>Fault</th>

</tr>

EOD;

$fault_details = '';

while ($row = mysql_fetch_array($result))

{

$jc_no = $row['jc_no'];

$date = $row['date'];

$section = $row['section'];

$itm_des = $row['itm_des'];

$itm_slno = $row['itm_slno'];

$fault_brf = $row['fault_brf'];

$fault_details .=<<<RAM

<tr>

<td>$jc_no</td>

<td>$date</td>

<td>$section</td>

<td>$itm_des</td>

<td>$itm_slno</td>

<td>$fault_brf</td>

</tr>

RAM;

}

$movie_footer ="</table>";

 

$movie =<<<MOVIE

$jc_no

$date

$section

$itm_des

$itm_slno

$fault_brf

MOVIE;

echo "There are $num_movies complains in our database";

echo $movie;

 

?>

 

I m using above code but it only display the last record please debug the code

Link to comment
https://forums.phpfreaks.com/topic/247822-please-hlp-me-populating-the-table/
Share on other sites

Most everything returned from the database query is stored in $fault_details, except for the values from the last iteration of the while() loop, which is stored in $movie. You echo $movie, but nowhere in that code do you ever echo $fault_details. That's why you only see the last result.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.