I am having issues with below code which display the news added in the database after few hours, the news is added straight away in the database once created and not sure if i need to make any changes in below code so it fetches the updated
$query="SELECT *
FROM
(
SELECT id,ext,database_id
FROM images
WHERE database_name='news' AND database_id IN(" . implode(',',array_keys($news)) . ")
ORDER BY role
) AS images
GROUP BY database_id";
2
Answers
I don’t see anything wrong with the script. However, there are few things you might want to consider:
Short tags are not recommended.
Are PHP short tags acceptable to use?
Using @ suppresses the warnings. You can disable error reporting instead of suppressing the warnings.
Using mysql isn’t recommended. Please use mysqli instead. When should I use MySQLi instead of MySQL?
This query makes no sense:
You are aggregating by
database_id
, but usingselect *
. MySQL is hopefully returning an error related to the group by.So, you should provide sample data, desired results, and an explanation of what you want to accomplish.