Displaying nsews entry from MySQL properly into html Tables?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Tom
Forum Newbie
Posts: 20
Joined: Sat Oct 05, 2002 5:24 pm
Location: Southwest FL

Displaying nsews entry from MySQL properly into html Tables?

Post 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
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

html

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Go for templates and have fun making it!
Tom
Forum Newbie
Posts: 20
Joined: Sat Oct 05, 2002 5:24 pm
Location: Southwest FL

okay

Post by Tom »

Thanks guys, I finally have it figured out :D

I appreciate all of your help,
-Tom
Post Reply