-1

Hi There I'm trying to get some data with this SELECT statement and when I just select two items it gives me result but when I place third item it doesn't give any result.

$Query="SELECT * from tableName WHERE status='true' AND gid='".$gid."' AND section='".$cid."'";

Plz any solution.

this one works fine, but when I add third item status='true'. doesn't work.

$Query="SELECT * from tableName WHERE gid='".$gid."' AND section='".$cid."'";
fguru
  • 71
  • 2
  • 9

2 Answers2

0

First, let me say this: Double-quoted strings can parse your variables, so this line can work, too:

$Query="SELECT * from tableName WHERE gid='$gid' AND SECTION='$cid'";

Try to learn PHP basics about using single ' and double " quotes here: What is the difference between single-quoted and double-quoted strings in PHP?

Related to the database query, is status field is present in your database table? If not, it should NOT be included within the database, or it will return FALSE boolean value. Instead, use IF if you want to be 'selectively' filtering the status of the table.

if('your conditions here'){
  $query = "SELECT * FROM tableName WHERE gid='$gid' AND section='$cid'";
}
Community
  • 1
  • 1
Andreas
  • 25
  • 3
0

I think your mistake is the status='true'

probable the database control its field with 1 or 0 value.

rLinhares
  • 367
  • 1
  • 4
  • 17