Hi, im a following a tutorial in order to create a eCommerce website, I’m at the early stages of the tutorial but I’ve come across a hurdle where I’m unable to display dynamic data from my website.
In myPHPadmin i have created a table with 2 rows (cat_id and cat_title). I’ve inserted data into these rows as follows;
cat_ids cat_title
1 chinese
2 japanese
3 malaysian
4 thai
this is the data I’m trying to display on my website.
Following the tutorial i created a functions.php file which contains the following code to retrieve the categories data.
<?php $con = mysqli_connect("localhost", "root", "", "ecommerce"); // getting the categories function getCats () { global $con; $get_cats = "select * from categories"; $run_cats = mysqli_query($con, $get_cats); while ($row_cats = mysql_fetch_array($run)) { $cat_id = $row_cats ['cat_ids']; $cat_title = $row_cats['cat_title']; echo "The next step was displaying this data to my index.php page which i did using the following code
<div id = "sidebar_title"> Menus </div>
<ul id= "cats">
<?php getCats (); ?>
<ul>
This should display the four categories i created according to the tutorial but it does not display on my index page which contains an include to the functions.php file. i receive no errors either. I’ve revised the code multiple times but can’t see any errors or anything different I’ve done.
Any help will be much appreciated.
Thank you.