The below code included in php file and gets data from data base
$sqlUrl = "SELECT *
FROM $category
WHERE sub_category = '$subCategory'";
$result = mysqli_query($con,$sqlUrl);
now I need to display those data on the screen and thus I would like to load them on am html file in a specific division
<div id="div6">
</div>
I think that I can do it using JScript but I don't know how to do it
2 Answers 2
What the ... If you just want to print it, you dont need JavaScript:
<div id="div6">
<?php foreach($result as $r) {
echo $r;
} ?>
</div>
answered Jan 17, 2014 at 9:07
Realitätsverlust
3,9532 gold badges27 silver badges46 bronze badges
Sign up to request clarification or add additional context in comments.
4 Comments
ginter
Actually is a phpBB board and I have tried to write php code inside the html file but it doesn't permit me. That's the reason I am trying to write JScript.
Realitätsverlust
You know that the file still has to be named as
file.php in order to actually write PHP into it right?ginter
Yes I know, I have already tried it but it creates trouble to other files on the phpBB board...
Realitätsverlust
Bad phpBB board then. Every normal board is able to do that. Honestly, i have no idea how you want to create dynamic input depending on the output of your database if you cant combine .php and .html
why you want to display results with JScript? You can do it like this also:
<div id="div6">
<?php
while ($row = mysqli_fetch_assoc($result)) {
echo $row["Name"]."<br />";
}
?>
</div>
for more details Plese refer: https://www.php.net/mysqli_fetch_assoc
answered Jan 17, 2014 at 9:08
user2936213
1,0111 gold badge8 silver badges19 bronze badges
2 Comments
Tun Zarni Kyaw
did you forget
<?php ?> tag or doesn't need <?php ?> tag?ginter
Actually is a phpBB board and I have tried to write php code inside the html file but it doesn't permit me. That's the reason I am trying to write JScript.
default
<?php print_r($result); ?>inside your<div>