I need some help adding a PHP code to my MySQL. Here is the code:
$query_qPosts = "SELECT * FROM front_news WHERE draft = 1 AND department_id = 1 OR department_id = 0 ORDER BY id DESC";
Where it says “department_id = 1” I need to replace 1 with <?php echo $id ?>.
In php you can encapsulate varibles inside double quotes and they will form part of the string.
e.g
Where as for single quotes you need to concatenate them in.
E.g.
In terms of which one you would use, it depends on the context you are using them in and normally it can be down to personal preference. Single quotes execute faster then double quotes.