mardi 1 janvier 2019

How to cancel a select statement when a WHERE parameter is empty or does not exist?

I hope someone can help me on this? Here's my select statement based on a session variable.

$users = 'SELECT * FROM wbcusers WHERE username = "'.$_SESSION['user'].'" ';

I want to be able to SELECT IF the session variable 'user' exists... IF NOT, I do not want to select anything and cancel the database query so I don't see a 'Notice: Undefined index: error' notice?

Any help on how this is done would be very much appreciated.

Thank you. Steve

Aucun commentaire:

Enregistrer un commentaire