best method to get all data

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
jaymoore_299
Forum Contributor
Posts: 128
Joined: Wed May 11, 2005 6:40 pm
Contact:

best method to get all data

Post by jaymoore_299 »

what's the best way to:
1. retrieve all data in a table
2. display the data retrieved so that it looks as it is stored.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

  1. Code: Select all

    SELECT * FROM `table`
    [*]a standard html table works well. For the most part, you can blindly display each column in a cell. The only real check you may want to do is check if a field is NULL. You can use [url=http://php.net/function.array_keys]array_keys()[/url] with the result from [url=http://php.net/function.mysql_fetch_assoc]mysql_fetch_assoc()[/url] to display the field names as the table header. Alternately, you can do a [url=http://dev.mysql.com/doc/mysql/en/describe.html]DESCRIBE[/url] to do some proportional calculations and type setting to fiddle with how it looks.[/list]
Post Reply