Hmm it's not working I think.
$sql = "SELECT C1.Name, C1.ID, C2.Name, C2.Link, C2.abbr FROM Categories C1, Categories C2 WHERE C1.ID=C2.belongsTo AND C1.ID<>C2.ID AND C1.Level=0 ORDER BY C1.Name, C2.Name";
if($stmt = $mysqli->prepare($sql)) {
if(!$stmt->execute()) {
echo 'The query could not be executed: '.$stmt->error;
} else {
$stmt->bind_result($Name,$ID);
while($stmt->fetch()) {
echo "<li>" . $Name;
echo "</li>";
}
}
$stmt->close();
} else {
echo 'Incorrect Query: '.$mysqli->error;
}
This return:
<li></li>
<li></li>
<li></li>
<li></li>
So only 4 results are returned instead of the 6 in my table and the variable $Name is unidentified. I'm probably doing it wrong since both prepared queries and joins are new to me.