Jump to content

Archived

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

jagguy

php in html

Recommended Posts

How do I embed php in html as this deosn't work, but it does work in a php script with no html in the same directory.

[code]

</head>
<body bgcolor="#ffffff"><?php $dbhost ="" 'localhost';

$conn = mysql_connect($dbhost,'root','') ;


$dbname = 'petstore';
mysql_select_db($dbname);


$query="select * from species";
$rt=mysql_query($query);

while($nt=mysql_fetch_array($rt))
{
echo "$nt[id] $nt[species] <br>";   
}


?>



</body>
</html>
[/code]

Share this post


Link to post
Share on other sites
... and why doesn't that work? are you naming the page a .php file? what error are you getting?

Share this post


Link to post
Share on other sites
[code]<?php $dbhost ="" 'localhost';
[/code]

should be:
[code]<?php $dbhost ='localhost';[/code]

Share this post


Link to post
Share on other sites
Hi

Ok I had an error on the php code I have been told, so now it works thanks.

I suppose the question is how can you format the values I get from mysql on the webpage. Csn I use css on them somehow or do i need to use php only.

Share this post


Link to post
Share on other sites
you can use CSS, javascript or any other client side technology on them after they've been retrieved via PHP. keep in mind that the browser [i]only sees[/i] what PHP feeds it, so when you generate your markup, just output classes and IDs as you want them to be for your CSS layout.

Share this post


Link to post
Share on other sites

×

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.