Solved

How do you echo back a database table?

Posted on 2008-10-02
2
193 Views
Last Modified: 2013-12-12
I cant rember how to echo back a table in my database, evertime i echo a collum it goes like this ..  entry1entry2, with no breaks, everytime i try to put a break in, its messes it up.
0
Comment
Question by:Lee-Bartlett
2 Comments
 

Author Comment

by:Lee-Bartlett
ID: 22629497
I got it kind of working so far with the code below, how would i wrap it in a table so there is atleast spacing between the entries
<?php  require_once("includes/db_connection.php"); ?>
 
 

<?php
 

$sql = "SELECT * from tblbasicform";

$res = mysql_query($sql) or die(mysql_error());
 
 

while($row = MYSQL_FETCH_ARRAY($res))

{

echo "$row[name]";

echo "$row[email]";

echo "$row[location]<br>";

}
 
 

?>

Open in new window

0
 
LVL 5

Accepted Solution

by:
jericotolentino earned 50 total points
ID: 22631050
How do you want your output to look like? Something like the one below?
echo '<table>';
 

while($row = MYSQL_FETCH_ARRAY($res))

{

echo '<tr>';

echo "<td>$row[name]</td>";

echo "<td>$row[email]</td>";

echo "<td>$row[location]</td>";

echo '</tr>';

}
 

</table>

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now