Not Null Query

A

Anonymous

Guest
Querys handle projections and restrictions
"select projection from table where restriction.

projections: wich fields do you want to see
restrictions: wich records do you want to see

you can't hide empty fields in some records and show them in other records. You need to live with that, or use 2 different query's

Greetz Daan
 
or try do

Code:
if ($data['name'] != "") 
{
echo "Name = $data[name]";
}

if ($data['email'] != "") 
{
echo "Emai l= $data[email]";
}

if ($data['age'] != "") 
{
echo "Age = $data[age]";
}
 
torosco said:
HELP! I'm trying to write a query that will display all values from a table exept the tuples that are null. For example I have a table
Name: John
Email: null
age:21

Name: Joe
email: joe@here.com
age: null

I want the query to show me:
Name: John
Age: 21

Name: Joe
email: joe@here.com

Thanks.
What you need is:
Code:
<?
$query = "select Name,email,Age from table";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
     foreach($row as $key => $value) {
          if (!is_null($value)) print "$key: $value\n";
     }
}
And that should sort it out
 
Back
Top