如果行不为空且不为空,如何显示该行?

I have a page that displays various fields from a mysql_query. I only want to display the following field/row when the value is available.

$web = $row['Website'];


<?php 
if ($web = NULL)
{?>
<!-- DO NOTHING -->
<?php
}
else
{?>
<tr>
<td valign='top' colspan='3' align='center'><DIV CLASS='standings_title'><?php echo $web ?></div></td>
</tr>
<?php
}
?>

Hopefully someone can tell me what I am doing wrong.

<?php if($web):?>
<tr>
<td valign='top' colspan='3' align='center'><DIV CLASS='standings_title'><?php echo $web ?></div></td>
</tr>
<?php endif; ?>

Use isset().

if(isset($web))
{

}

Or

if($web)
{

}
$web = $row['Website'];
// Trim whitespace so a single blank space doesn't display as a populated value.
$web = trim($web);
if (!empty($web) {
  // Display it.
}
if (isset($value) && strlen($value) > 0) {
  //stuff
}

This is better than using empty($value) or just a if($value) because php considers things such as "0" as empty. However, if you can guarantee that value will never be "0", they are functionally equivalent, and !empty($value) will be faster.

From the php manual:

The following things are considered to be empty:

"" (an empty string)
0 (0 as an integer)
0.0 (0 as a float)
"0" (0 as a string)
NULL
FALSE
array() (an empty array)
var $var; (a variable declared, but without a value in a class)

Post column of the row if is not null (in PDO):

    $sql = 'SELECT * FROM posts where post_date !="" ';
    $stmt = $database->prepare($sql);
    $stmt->execute();
    $rowCount = $stmt->rowCount(); 

    if($rowCount < 1)
    {
        return null;
    }
    else
    {
      do somthing ...
    }