Solved

How do you echo back a database table?

Posted on 2008-10-02
2
194 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

896 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

19 Experts available now in Live!

Get 1:1 Help Now