Jump to content

Help For My Poorness Knowledge


ltdangkhoa
 Share

Recommended Posts

i have a html file with tag below

<div id ="no1"></div>

and a php file

<?php $result = mysql_query("SELECT * FROM  `news` ") OR die(mysql_error());echo $result;?>

how can i put $result into "no1" div?my html file is template file so i can't run php into this tag, is there any way?thanks for your attention...

Link to comment
Share on other sites

The usual thing would look like this:<div id ="no1"><?php echo $result; ?></div>or this:echo "<div id =\"no1\">$result</div>";or even:echo '<div id ="no1">' . $result . '</div>';

my html file is template file so i can't run php into this tag, is there any way?
I'm not sure what you mean. Mixing PHP with your HTML is pretty much what template files do.
Link to comment
Share on other sites

You can simply position the PHP code inside the div:

<div id="no1"><?php $result = mysql_query("SELECT * FROM  `news` ") OR die(mysql_error());echo $result;?></div>

There are more complicated ways using AJAX, but this is the easiest and doesn't depend on the user having JavaScript enabled.

Link to comment
Share on other sites

You can simply position the PHP code inside the div:
<div id="no1"><?php $result = mysql_query("SELECT * FROM  `news` ") OR die(mysql_error());echo $result;?></div>

There are more complicated ways using AJAX, but this is the easiest and doesn't depend on the user having JavaScript enabled.

great, i think u are right.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...