returning data to a table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

Post by Straterra »

Those tutorials are crap? 8O I beg to differ, sir. I think Dreamweaver is the one that is crap. As I will always say, write your own HTML. Better custimization, and gives you much much more satisfaction!
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Notepad is the best way to go...

I look at dreamweaver coded html sites and you can spot it a mile a way :d
Vicious
Forum Contributor
Posts: 105
Joined: Fri Jun 20, 2003 12:40 pm

Post by Vicious »

the template was made in notepad. But i was having so much trouble from the one person saying i cant make tables so i made it in dreamweaver.
Vicious
Forum Contributor
Posts: 105
Joined: Fri Jun 20, 2003 12:40 pm

Post by Vicious »

id like to apologize for my rude attitude and you guys are doing your best to help me. I ve had very lil sleep these last couple days. All im looking for is someone to tell me how i can bring in the table i have and display the info. Thanks
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

Ok, took a look at that example table and you're code. All you have to do is combine them to output a table:

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";
}
?>
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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Godamnit you beat me to it :D

Instead of continuously using echo function you can do this

Code: Select all

<?php

echo "sdlkfjlskdjflksdjflkj"
        ."dkfjflksdjfkldjfklj"
        ."fkjdklfjlksdj";


?>
User avatar
Derfel Cadarn
Forum Contributor
Posts: 193
Joined: Thu Jul 17, 2003 12:02 pm
Location: Berlin, Germany

Post by Derfel Cadarn »

Phenom wrote:Instead of continuously using echo function you can do this

Code: Select all

<?php

echo "sdlkfjlskdjflksdjflkj"
        ."dkfjflksdjfkldjfklj"
        ."fkjdklfjlksdj";


?>
Nay not here? He'd say: HEREDOC-it:

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;

?>
Post Reply