如果mysql任何字段为空,则显示一个像null的单词

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);
 ?>`
查看全部
doutang8098
doutang8098
2016/01/15 21:19
  • php
  • html
  • mysql
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

2个回复