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