jlsohio
07-23-2003, 12:37 AM
I'm using a php script to display data that I stored in mysql database. I'm displaying news headlines, usually 2 or 3 sentances each. The problem I'm having is when I display them on my page, there's no space between each headline. They all run together in one giant papragraph. My database is very simple, it only has two fields in it: date field & news field.
How can I separate each headline to make it easier to read?
Here's my php script:
?>
//Begin your table outside of the array
echo "<table border=0 bordercolorlight=brown bordercolordark=brown bgcolor=ffff00 width=95%>\n";
$table_row = "<tr align=\"center\" valign=\"middle\">";
$table_row .= "<th>Date</th>";
$table_row .= "<th>News</th>";
echo "$table_row\n";
// Request the text of all the news data
$result = mysql_query("SELECT DATE_FORMAT(date, '%m-%d-%y') AS formattedDate , news FROM news ORDER BY date DESC");
if (!$result) {
die('<p>Error performing query: ' . mysql_error() . '</p>');
}
// Display the text of each headline
while ( $row = mysql_fetch_array($result) ) {
//$date = date("d M Y",$row["date"]);
$table_row = "<tr align=\"justify\" valign=\"middle\">";
$table_row .= "<td WIDTH=10%><font size=\"3\"><font face=\"arial\">$row[formattedDate]</td>";
$table_row .= "<td WIDTH=90%><font size=\"3\"><font face=\"arial\">$row[news]</td>";
echo "$table_row\n";
}
?>
How can I separate each headline to make it easier to read?
Here's my php script:
?>
//Begin your table outside of the array
echo "<table border=0 bordercolorlight=brown bordercolordark=brown bgcolor=ffff00 width=95%>\n";
$table_row = "<tr align=\"center\" valign=\"middle\">";
$table_row .= "<th>Date</th>";
$table_row .= "<th>News</th>";
echo "$table_row\n";
// Request the text of all the news data
$result = mysql_query("SELECT DATE_FORMAT(date, '%m-%d-%y') AS formattedDate , news FROM news ORDER BY date DESC");
if (!$result) {
die('<p>Error performing query: ' . mysql_error() . '</p>');
}
// Display the text of each headline
while ( $row = mysql_fetch_array($result) ) {
//$date = date("d M Y",$row["date"]);
$table_row = "<tr align=\"justify\" valign=\"middle\">";
$table_row .= "<td WIDTH=10%><font size=\"3\"><font face=\"arial\">$row[formattedDate]</td>";
$table_row .= "<td WIDTH=90%><font size=\"3\"><font face=\"arial\">$row[news]</td>";
echo "$table_row\n";
}
?>