ltdangkhoa Posted October 6, 2009 Share Posted October 6, 2009 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 More sharing options...
jeffman Posted October 6, 2009 Share Posted October 6, 2009 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 More sharing options...
chibineku Posted October 6, 2009 Share Posted October 6, 2009 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 More sharing options...
Guest feng Posted October 8, 2009 Share Posted October 8, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.