Reputation: 4649
Let's focus on event_table column. What I'm trying to do is getting all value except for "0"
Here is my query for that,
$query = "SELECT DISTINCT event_table FROM embedded_page WHERE event_table <> 0 AND uid='". $uid ."'";
$result = db_query($query);
foreach ($result as $r) {
echo $r->event_table;
}
I'm trying to select event_table's values with distinct to prevent duplication. but since, I'm using the operator <> for some reason, it doesn't work. when I echoed it, no output
if I removed the event_table <> 0 it outputs 0, giveaway_table, and poll
Upvotes: 0
Views: 59
Reputation: 10784
Try
event_table <> '0'
You are comparing to a string column, but specifying an integer value, and it appears that either PDO or your underlying database is not handling the int to string conversion in the way you expect.
Also, your code sample is vulnerable to Sql Injection attacks.
Upvotes: 4