I have the following snippet of php code in which I am trying to have the output be NULL if the php query does not yield any results but if it does yield results I have the output to be NOT NULL.
$dbconnSrc = pg_connect("host=$dbhost dbname=$dbname user=$dbuser password=$dbpass") or die ("Could not connect");
$sql="select area, radius from circle where level>50;
$res = pg_query($dbconnSrc, $sql);
var_dump(isset($res));
echo "$res\n";
while($row = pg_fetch_array($res, NULL, PGSQL_ASSOC))
{
$radius=$row["radius"];
print "radius is $radius\n";
if (isset($radius)){
echo "NOT NULL\n";
}
else
{
echo "NULL\n";
}
}
Unfortunately, I am not getting the desired results, so I was wondering if anyone knows who to tweak this code to get the desired results.
Aucun commentaire:
Enregistrer un commentaire