returning data to a table
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Ok, took a look at that example table and you're code. All you have to do is combine them to output a table:
BTW, you are mixing old and new HTML. The <font> tag has been deprecated and CSS is now gaining mass popularity. You should look into it:
http://www.w3schools.com/css/default.asp
Code: Select all
<?php
$db = mysql_connect("localhost","","") or die ("cant connect");
mysql_select_db("team101",$db) or die ("cant change");
$news = mysql_query("select * from team101_news ORDER BY date DESC LIMIT 8") or die ("cant get em");
while($rows = mysql_fetch_array($news))
{
$date = $rows["date"];
$author = $rows["author"];
$title = $rows["title"];
$content = $rows["content"];
$number = "100%";
echo "<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#333333" width="50%" id="AutoNumber1" height="64">\n";
echo "<tr>\n";
echo "<td width="100%" bordercolor="#000000" bgcolor="#FF9900" height="19">\n";
echo "<font face="Verdana" style="font-size: 12px" color="#FFFFFF">\n";
echo $title . "<br />" . $date;
echo "</tr>\n";
echo "<tr>\n";
echo "<td width="100%" bgcolor="#525252" height="24">\n";
echo "<font color="#FFFFFF" face="Verdana" style="font-size: 12px">\n";
echo $content;
echo "</font></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td width="100%" bgcolor="#808080" height="19">\n";
echo $author;
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
}
?>http://www.w3schools.com/css/default.asp
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Godamnit you beat me to it 
Instead of continuously using echo function you can do this
Instead of continuously using echo function you can do this
Code: Select all
<?php
echo "sdlkfjlskdjflksdjflkj"
."dkfjflksdjfkldjfklj"
."fkjdklfjlksdj";
?>- Derfel Cadarn
- Forum Contributor
- Posts: 193
- Joined: Thu Jul 17, 2003 12:02 pm
- Location: Berlin, Germany
Nay not here? He'd say: HEREDOC-it:Phenom wrote:Instead of continuously using echo function you can do thisCode: Select all
<?php echo "sdlkfjlskdjflksdjflkj" ."dkfjflksdjfkldjfklj" ."fkjdklfjlksdj"; ?>
Code: Select all
echo <<<HEREDOC and then you can type all the text
you want, but i do not feel like typing a lot at the moment
so you'll have to believe me or just ask Nay!
HEREDOC;
?>