I already have a function where you can insert data to the database which then prints out all the "item_name"s on the index with their respective "item_name" as url (example.com/example_name)
To dumb the code down lets say item_name is the only row I have, and I want each item to have it's own page that says "My item: example_name". Here is the code I'm currently using for printing the list of items:
<?php
$sql = "SELECT * FROM items ORDER BY item_name DESC";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo '
<p>
<a href="/' . $row["item_name"] . '"> ' . $row["item_name"] . ' </a>
</p> ';
}
} else {
echo "0 results";
}
$conn->close();
?>
What is the simplest way to go about doint this? Security is no big issue here. Sorry if duplicate question, I have searched for over 2 hours now without finding anything directly applying to my issue. I am pretty new to programming in general so please don't go very technical on me. Thank you.