Page 1 of 1

Displaying nsews entry from MySQL properly into html Tables?

Posted: Sat Oct 26, 2002 9:22 am
by Tom
Hey Guys (and girls),
I recently just began using MySQL, and I guess you could say I'm still in the "experimenting" stages. I'm currently trying to create a news script where the two admins of our site to be (FLballer.com) can go to something like /admin/postnews.php or something of that sort to post the news, and then have the news be displayed on the main page. I've got a little bit of knowledge on how to pull information out of a database, but I want to put it nicely into HTML tables.

So here are my questions:
1) If I'm pulling multiple entries from a database, must i create and echo the HTML table in the "while(){}" loop or can I create the html table outside of the PHP script and insert the information into by putting like..
<?php echo "$blah"; ?> into a td or something?

Hehe. I hope you guys can understand what I'm trying to ask :wink:

Take it easy, - Tom

html

Posted: Sat Oct 26, 2002 12:05 pm
by AVATAr
There are two approaches on this:

1) you can make your html in the while... (the simpler but harder to mantain). You can make a function like: print_line($line) that returns the line of the table and you echo it.

2) using templates (more complicated... but grat to mantain) (fast templates and stuff) search the forum

hope it helps

Posted: Sun Oct 27, 2002 4:28 am
by volka
a few days ago I received a mail from phpClasses
A new class was added to "PHP Classes" repository.

Name: CTable

Author: David Higgins <higginsd@zoulcreations.com>

Description:
This class helps aid in the generation of table output from a database
recordset, or other form of data source.

URL: http://www.phpclasses.org/browse.html/package/823.html

Posted: Sun Oct 27, 2002 4:45 am
by Takuma
Go for templates and have fun making it!

okay

Posted: Thu Oct 31, 2002 10:44 pm
by Tom
Thanks guys, I finally have it figured out :D

I appreciate all of your help,
-Tom