I need to know that, if there is any empty field then display null in retrieve form. i mean,
name----------age----------country
xyz----------" "---------usa
so, the form will show
name: xyz
age: show null
country: usa
<?php
$dbhost = '';
$dbuser = '';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn ) {
die('Could not connect: ' . mysql_error());
}
$No=$_GET['No'];
$sql = "SELECT * from tablename where Name='$Name'";
mysql_select_db('dbname');
$retval = mysql_query( $sql, $conn );
if(! $retval ) {
die('Could not get data: ' . mysql_error());
}
while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) {
?>
<table width="100%"><tr><td>
<table>
<tr>
<tr><td class="a" style="width:20%">Name</td><td style="width:20%" class="a"><a class="res" ><?php echo $row['Name'];?></a></td></tr>
<tr><td class="a" style="width:20%">age</td><td style="width:20%" class="a"><a class="res"><?php echo $row['age'];?></a></td></tr>
<tr><td class="a" style="width:20%">country</td><td style="width:20%" class="a"><a class="res"><?php echo $row['country'];?></a></td></tr>
</tr>
</table>
<?php
}
mysql_close($conn);
?>`
Just test if the result is empty and if it is show Null.
<?php if ($row['Name'] != '') {
echo $row['Name'];
} else {
echo "Null";
}?>
echo empty($row['age']) ? 'null' : $row['age']
PS: avoid SQL Injection!