Syntax Question
Posted: Tue Jun 22, 2004 1:15 pm
What is the proper syntax to include and if statement while trying to write out a query? Basically, this value might be in the DB... if it is it needs to be in the query with a comma but if it's not it shouldn't be in the query with a comma.
The IN statement of the query is where my question is directed at:
The IN statement of the query is where my question is directed at:
Code: Select all
$sql2 = 'SELECT username'
. ' FROM sgforum_users'
. ' WHERE user_id'
. ' IN ( '.$row1['user_id_1'].''.if (isset($row1['user_id_2'])) echo (','.$row1['user_id_2']).''.if (isset($row1['user_id_3'])) echo (','.$row1['user_id_3']).''.if (isset($row1['user_id_4'])) echo (','.$row1['user_id_4']).' ) LIMIT 0, 30';
echo $sql2;