coolagniho Posted September 25, 2011 Share Posted September 25, 2011 <?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 Quote Link to comment https://forums.phpfreaks.com/topic/247822-please-hlp-me-populating-the-table/ Share on other sites More sharing options...
AyKay47 Posted September 25, 2011 Share Posted September 25, 2011 first glance i don't see anything wrong.. how many rows is your query actually grabbing? view the page source to see what it's doing. Quote Link to comment https://forums.phpfreaks.com/topic/247822-please-hlp-me-populating-the-table/#findComment-1272585 Share on other sites More sharing options...
coolagniho Posted September 25, 2011 Author Share Posted September 25, 2011 sir Im using 4rows n 6coloms but the problem is it displaying only last row Quote Link to comment https://forums.phpfreaks.com/topic/247822-please-hlp-me-populating-the-table/#findComment-1272650 Share on other sites More sharing options...
AyKay47 Posted September 25, 2011 Share Posted September 25, 2011 you didn't answer either of my questions.. Quote Link to comment https://forums.phpfreaks.com/topic/247822-please-hlp-me-populating-the-table/#findComment-1272680 Share on other sites More sharing options...
Pikachu2000 Posted September 25, 2011 Share Posted September 25, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/247822-please-hlp-me-populating-the-table/#findComment-1272682 Share on other sites More sharing options...
coolagniho Posted September 27, 2011 Author Share Posted September 27, 2011 i did that also but giving following error Notice: Undefined variable: fault_detail in C:\Documents and Settings\agni\Desktop\xampp-win32-1.7.4-VC6-1\xampp\htdocs\www\test2.php on line 58 Quote Link to comment https://forums.phpfreaks.com/topic/247822-please-hlp-me-populating-the-table/#findComment-1273295 Share on other sites More sharing options...
Pikachu2000 Posted September 27, 2011 Share Posted September 27, 2011 You spelled it wrong. Quote Link to comment https://forums.phpfreaks.com/topic/247822-please-hlp-me-populating-the-table/#findComment-1273298 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.