This code is only returning one row from the categories table
Here is what the table looks like:
id category_title category_description
1 title1 description 1
2 title2 description 2
3 title 3 description 1
4 title 4 description 1
But only the 3rd row is being shown
[php]<?php
//Select all from the categories table and order by the category title in ascending order (ASC)
$sql = "SELECT * FROM categories";
//$res = the result of the above query or die if error
$result = mysqli_query($DBconnect, $sql) or die (mysqli_error());
//If the result has more than 0 rows
if (mysqli_num_rows($result) > 0) {
//then while $row = what has been fetched from the database
while ($row = mysqli_fetch_assoc($result)) {
$id = $row['id'];
$title = $row['category_title'];
$description = $row['category_description'];
//Makes link the titles of the category and the description
$categories = "<a href='#'>".$title." ".$description."</a>";
}
echo $categories;
} else {
echo "No table found";
}[/php]