Help with tables
Posted: Thu Jan 29, 2004 4:23 pm
ok, so i have this code that pulls data from my mySQL database.
i want the table to display the most recent post first (in reverse order using the primary key identifyer)
any idea how to implement this... i'm a newbie!
thanks,
mjar81
i want the table to display the most recent post first (in reverse order using the primary key identifyer)
Code: Select all
<TABLE align="center" border="1" cellpadding="2" cellspacing="0" bordercolor="000000" width="80%">
<?php
//connect to the database "localhost" using the supplied
//username and password and assign it the variable $db
$db = mysql_connect("localhost", "mjar81", "******");
//select the database "prayer" from mySQL
mysql_select_db("prayer",$db);
//assign the variable $result to everything from the "prayer_content" table
$result = mysql_query("SELECT * FROM prayer_content",$db);
//this outputs html to format the table and input some text
echo"<TR><TD><B>Name:</B><TD><B>Request:</B><TD><B>Date Submitted:</B><TD><B>Email:</B></TR>";
//while loop assigning $myrow to the $result array
while($myrow = mysql_fetch_array($result))
{
echo "<TR><TD>";
echo $myrowї"name"];
echo "<TD>";
echo $myrowї"request"];
echo "<td>";
echo $myrowї"date"];
echo "<br \>";
echo $myrowї"time"];
echo "<TD>";
//if statement to decide whether or not to display the email
if($myrowї"displayemail"] == 1)
{
//email display function
//html code
echo "<a href=mailto:";
echo $myrowї"email"];
echo ">";
echo $myrowї"email"];
echo "</a>";
}
else
{
//don't display the e-mail
echo "Hidden.";
}
}
//close the table
echo "</TABLE>";
?>thanks,
mjar81