I got it to work with the code below which is just fetching my columns and rows and display. I’m not sure if this is bad code?..i’m not very advanced in php. Is there any security risk with the code below?
$con = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
//Query database
$query= mysqli_query($con, "SELECT * FROM categories");
$numrows= mysqli_num_rows($query);
if ($numrows){
$I = 1;
while($row = mysqli_fetch_assoc($query)){
$cat_name = $row['cat_name'];
$cat_num = $row['cat_num'];
echo "$cat_name, $cat_num, $I<br />";
$I++;
}
}
?>