How to use query result as global?
Posted: Mon Mar 25, 2013 10:48 am
Hi there,
I have a critical condition. I want to check a mysql field value whether it is empty or not. If empty then to show 'No Value' else show the value. So I want to execute following query:
But nothing is outputting except html part Fullname: and Lastname. No mysql error is coming if I add 'or die(mysql_error())' at the end of mysql_query.
How I can accomplish the above condition and display mysql field value?
Best Regards
I have a critical condition. I want to check a mysql field value whether it is empty or not. If empty then to show 'No Value' else show the value. So I want to execute following query:
Code: Select all
<?php
function checkv($field){
global $row;
if ($row[$field]=""){
echo 'No value;
}else{
echo $row[$field];
}
}
$result = mysql_query("SELECT * FROM $table WHERE some_column=some_condition");
while($row=mysql_fetch_assoc($result){
?>
Fullname: <?php checkv(fullname); ?>
Lastname: <?php checkv(lastname); ?>
<?php
}
?>How I can accomplish the above condition and display mysql field value?
Best Regards