Good afternoon, dear experts. I have a sql request for php
$id = 10;
$row = $db->super_query( "SELECT * FROM " . PREFIX . "_news WHERE id = '{$id}'" );
I have two cells in the db - allowed_countries and notallowed_countries. How do I add conditions to the request so that it works like this:
(if allowed_countries not empty and allowed_countries == 'en' then show result of query, else if allowed_countries is empty then show result of query) AND (if notallowed_countries not empty and notallowed_countries != 'fr' then show result of query, else if notallowed_countries is empty then show result of query)
$id = 10;
$allowed_countries = 'en';
$notallowed_countries = 'fr';
$row = $db->super_query( "SELECT * FROM " . PREFIX . "_news (if allowed_countries not empty and allowed_countries == '{$allowed_countries}' then
show result of query, else if allowed_countries is empty then show
result of query) AND (if notallowed_countries not empty and
notallowed_countries != '{$notallowed_countries}' then show result of query, else if
notallowed_countries is empty then show result of query) WHERE id = '{$id}'" );
Thanks for your answers and have a nice day.
Aucun commentaire:
Enregistrer un commentaire