Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
formatting database output
Old 08-21-2008, 10:24 AM formatting output
Average Talker

Posts: 18
Name: joseph
Trades: 0
i have my webpage displaying content from my database, title of post and the actual post itself. do i create a table and have them display in it or what can i do to tidy it up or what are the options?? here is my code and what it looks like.. thanks alot.

<?php
$con = mysql_connect("socweb3.napier.ac.uk","a6005321","5 change");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("a6005321", $con);
$var = mysql_query("SELECT * FROM posts");

while($row = mysql_fetch_array($var)){
echo $row['title'];
echo $row['post'];
echo "<hr />";
}

//
mysql_close($con);
Attached Images
File Type: jpg copy.JPG (15.6 KB, 2 views)

Last edited by ajm22386; 08-21-2008 at 10:42 AM..
ajm22386 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-21-2008, 12:39 PM Re: formatting database output
Junior Talker

Posts: 3
Name: Joseph
Trades: 0
Using a table will be the easiest and simplest way to format the data. You can do it as follows:

PHP Code:
echo "<table>";
echo 
"<tr><td>Title</td><td>Post</td></tr>";

while(
$row mysql_fetch_array($var)){
      echo 
"<tr>";
      echo 
"<td>" $row['title'] . "</td>";
      echo 
"<td>" $row['post'] . "</td>";
      echo 
"</tr>";
}

echo 
"</table>"
jthayne is offline
Reply With Quote
View Public Profile
 
Old 08-21-2008, 04:13 PM Re: formatting database output
Average Talker

Posts: 18
Name: joseph
Trades: 0
thanks alot mate . worked brilliant.
ajm22386 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to formatting database output
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11670 seconds with 13 queries