I start learning PHP quite recently,and I met a frustrating problem in which the code seems good, but it just won't work,even the one who teach me don't know what cause it. Below I'll paste my code to you.
<?php
header("content-type: text/html; charset = UTF-8");
$con = new mysqli();
$con -> connect("localhost", "root" ,"");
$con -> select_db("test_db");
$con -> query("set names UTF8");
$query = $con -> query("SELECT * FROM TITLES LIMIT 0,2");
$num = $query -> num_rows;
for ($i=1 ; $i <= $num; $i++)
{
$result = $query -> fetch_array();
echo "<table style ='float: left'>";
echo "<tr><th>".$result["TITLE"]."</th><tr>";
echo "<tr><td>";
include("$i.php");
echo "</td></tr>";
echo "</table>";
}
?>
And the result turn to be this:
By the way,I'm using XAMPP 7.0.1 in MAC.
<?php
header("content-tupe: text/html; charset = UTF-8");
$con = new mysqli();
$con -> connect("localhost", "root" ,"");
$con -> select_db("test_db");
$con -> query("set names UTF8");
$query = $con -> query("SELECT * FROM PHP_MANUAL LIMIT 0,6");
?>
<ul>
<?php
while ($result = $query -> fetch_array())
{
echo "<li>".$result["CONTENT"]."</li>";
}
?>
</ul>