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
Share on other sites

The process is basically like this:

 

PHP -> HTML <- CSS

 

Php outputs the HTML. You use CSS to act upon that HTML. The CSS doesn't do anything to the php (it cant - php isn't a 'thing' its more of an 'action', to give a bit of a metaphor.)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.