PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$query = "SELECT concat(u_first_name, ' ', u_last_name) AS name FROM users WHERE u_group=1 AND u_group=2";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
echo "<select name=\"submitter\" id=\"submitter\">";
echo "<option value=\"0\" selected>Employee</option>";
while ($row = mysql_fetch_array($result)) {
printf ("<option value=\"{$row['name']}\">{$row['name']}</option>/n");
}
echo"</select>";
When I do this, no informatin is display, I than remove "AND u_group=2" from $query and it works...
is the code wrong? or how do I get two rows from MySQL?
SELECT concat(u_first_name, ' ', u_last_name) AS name FROM users WHERE u_group=1 AND u_group=2
A record has to match all the parts of the where clause in a SQL statement. u_group can't be both 1 and 2 at the same time, so it'll never match. You probably want "where u_group=1 OR u_group=2".