Jump to content

Format output of MYSQL in HTML


lucy

Recommended Posts

I am trying to write a blog for a website. I have written the data entry in PHP and HTML and also have written a data retrival in PHP. The problem is, the data retrival is not formated very well, i.e. it is only text, i cant change the colour, size or anything of it in the PHP file.

 

Could someone please advise me how i can include the php file in the HTML file and then format the output via HTML.

 

Below is my PHP file for data retrival which has a little formatting:

<?

$user="n-web53-blogger"; //specially created username
$password="password";
$database="web53-blog";

//connect to the database
$con = mysql_connect("localhost",$user,$password) or die ('Could not connect: ' . mysql_error());

//select the database
mysql_select_db($database, $con);

// query to select all records and convert to result
$query=mysql_query("SELECT * FROM table1");


while ($row = mysql_fetch_array($query))
{
$title = $row["title"];
$date = $row["date"];
$message = $row["message"];
$author = $row["author"];

	//print results
echo $title."<br> ";
echo $date."<br> ";
echo $message."<br> ";
echo $author."<br> ";
echo "----------------------------------------";
echo " <br>";


}

//close connection
mysql_close();

?>

 

Please can someone help me in formatting the output via HTML

 

Thanks,

Lucy

Link to comment
https://forums.phpfreaks.com/topic/168642-format-output-of-mysql-in-html/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.