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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.