Anyone who can help on how to apply MariaDB: IF-THEN-ELSE Statement in PHP.
I want to query when the account type is Admin and he/she created the data in pre_registered table the Cancelled status also display in the list but if he/she is Admin but not the on who created the data it will not display on the list. If normal user is logged in the system, the Cancelled status will not be included in the list.
I have try the below query but did not work.
<?php
$account_type = getActiveAccountType($connect);
$query = "SELECT * FROM pre_registered WHERE ";
if ($account_type == 'Admin') {
$query .= "
IF registered_created_by != ".$_SESSION['account_id']." THEN
{
registered_status != 'Cancelled'
}
END IF;
";
} else if ($account_type == 'User') {
$query .= "
registered_status != 'Cancelled'
";
}
I am new to programming as well, but I hope this helps.
Try getting the results first and write a condition that checks if registered_created_by == $_SESSION['account_id'], then show the column if it does and hide if it doesnt.