Displaying data from database on tables but with different query

hi guys im a student studying php and sql

In my code i am able to display data and add new table for every 2 data.

here is the code:
[php]$query = “SELECT * FROM student ORDER BY average DESC”;
$result = mysql_query($query);
$num = mysql_numrows($result);

echo “


”;

$i = 1;
while($row = mysql_fetch_assoc($result)) {
echo “

”;
// end and create a new table every 2 rows
if ($i % 2 === 0) {
	echo "</table>";
	echo "<table cellpadding=2 border=1><tr><td>StudentID</td><td>Name</td><td>average</td><td>date</td></tr><br />";
}
$i++;

}

echo “

StudentID Name average Date
” . $row[‘studentID’] . “ ” . $row[‘lastname’] . ", " . $row[‘firstname’] . “ ” . $row[‘average’] . “ ” . $row[‘date’] . “
”;[/php]

here is the output of my code:

StudentID Name average Date
2 dela cruz, juan 89.56 2013-02-07 05:28:42
6 dela pena, miggel 88.00 2013-02-09 04:10:10

StudentID Name average date
5 baltazar, sarah 87.45 2013-02-09 06:15:16
3 cruz, pedro 86.56 2013-02-09 07:16:26

StudentID Name average date
4 abanto, nicolas 83.56 2013-02-09 04:10:28
1 acebuche, joseph lance 80.56 2013-02-09 01:28:33

StudentID Name average date

i accidentally clicked the post

my problem is i want the 2nd and 3rd table to display data order by date on desc.

Do 2 queries.

Sponsor our Newsletter | Privacy Policy | Terms of Service