I’m new here and I just need a little help for my university assignment.
I’m making a simple php shop and i have a database with categories and items. I found a way to make the categories display on the page and go to a certain link when clicked but because the categories are listed dynamically i want the url to be written dynamically too…
i have this so far:
[php]
if (isset($_GET[“cat_id”])) {
if ($_GET[“cat_id”] == $cat_id) {
//get items
$get_items_sql = “SELECT item_id, item_title, item_price FROM store_items WHERE cat_id = '”.$cat_id."’ ORDER BY item_title";
$get_items_res = mysqli_query($mysqli, $get_items_sql) or die(mysqli_error($mysqli));
if (mysqli_num_rows($get_items_res) < 1) {
$display_block = "<p><em>Sorry, no items in this category :P.</em></p>";
}
else {
header("Location: http://mylink.com/");
exit;
}
//free results
mysqli_free_result($get_items_res);
}
}
[/php]
I want the link to have the category title variable so that it goes to a page that i will have built with the items of that category. something like:
http://mylink.com/‘cat_variable’.php
I hope I managed to explain myself and get some tips. Thanks.