manjumadhav93 Posted September 22, 2014 Share Posted September 22, 2014 (edited) Sorry for the beginner question, here I'm trying to retrieve data from the database and display it in the table format. But only table headers are printed, and not the actual values. The count variable is echoing 2 saying that data is present and correctly retrieved. Can anyone help? <?php include 'connect.php'; error_reporting(E_ALL ^ E_DEPRECATED); error_reporting(E_ERROR | E_PARSE); $sql="SELECT * FROM `resources` as r INNER JOIN `project_resources` as pr ON r.res_id =pr.res_id WHERE project_id='$_POST[project_id]'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($result === FALSE) { die(mysql_error()); } echo "$count"; echo '<table> <tr> <th>Resource ID</th> <th>Resource Name</th> <th>Email</th> <th>Phone Number</th> <th>Reporting Manager</th> <th>Role</th> <th>Designation</th> </tr>'; while ($row = mysql_fetch_array($result)) { echo ' <tr> <td>'.$row['res_id'].'</td> <td>'.$row['res_name'].'</td> <td>'.$row['email'].'</td> <td>'.$row['phone_number'].'</td> <td>'.$row['reporting_manager'].'</td> <td>'.$row['role'].'</td> <td>'.$row['designation'].'</td> </tr>'; } echo ' </table>'; ?> Edited September 22, 2014 by mac_gyver code tags please Quote Link to comment https://forums.phpfreaks.com/topic/291214-not-able-to-display-data-in-table-format-in-php/ Share on other sites More sharing options...
mac_gyver Posted September 22, 2014 Share Posted September 22, 2014 your code looks like it should work. what does a 'view source' in your browser show? if there are empty html-table rows, then it's likely your database table names don't match exactly the $row[...] index names, which would result in php error messages if you have php's error_reporting/display_errors turned full on. Quote Link to comment https://forums.phpfreaks.com/topic/291214-not-able-to-display-data-in-table-format-in-php/#findComment-1491793 Share on other sites More sharing options...
cyberRobot Posted September 22, 2014 Share Posted September 22, 2014 Inside your while loop, you can see what $row contains by doing something like this: <?php //... while($row = mysql_fetch_array($result)) { echo '<pre>' . print_r($row, true) . '</pre>'; //... } //... ?> Quote Link to comment https://forums.phpfreaks.com/topic/291214-not-able-to-display-data-in-table-format-in-php/#findComment-1491794 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.