Jump to content

Retrive data and fill table


mikebyrne

Recommended Posts

I'm trying to retrive data from my database and fill the table but all I mange to get is "The users could not be retrieved" and ive no idea where im going wrong my code is

 

<?php # Script - StudentEnrolled.php
// This will retrieve all the records from the Student table

$page_title = 'View the Current Users';

// Page header
echo '<h1 id="mainhead">Registered Users </h1>';

require_once ('mysql_connect.php'); //Connect to database

//Make a query
$query = "SELECT (Surname, ', ', Name) AS name, DATE FORMAT(Date_Registered, '%M %d, %Y') AS date FROM student_entry_details ORDER BY Date_Registered ASC";
$result = mysql_query ($query); // Run query

if ($result) { // If it ran OK , display the records.

// Create table
echo '<table align="center"
cellspacing="0" cellspacing="5">
<tr><td align="left"><b>Name</b></td>
<td align="left"><b>Date_Registered</b>
<td align="right"><b>CV Info</b>
</td></tr>';

//Fetch and print all records.
while ($row = mysql_fetch_array
($result, MYSQL_ASSOC)) {
echo '<tr><td align="left">' .
$row['name'] . '</td><td align="left">' . $row['date'] . '</td></tr>';

}
echo '</table>';

mysql_free_result ($result); //Free up the resources.

} else { // If it did not run OK.
echo '<p class="error">The users could not be retrieved.</p>';
}

mysql_close(); //Close the database connection
?>

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/96804-retrive-data-and-fill-table/
Share on other sites

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.