Re: Table shows even when if () is false

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The definition of 'empty' changed several times in the life of PHP.

I think an empty array was always empty though...

Still, if it's giving you grief, just use http://php.net/count

On Wed, August 22, 2007 4:06 pm, Dan Shirah wrote:
> From my understanding, if $result_deferred_comments is empty, than
> none of
> the code below the if should be executed, correct?
>
> The actualy rows/columns that would contain the data do not appear,
> but I am
> still seeing the "DEFERRED PAYMENT REQUEST COMMENTS" table. Is the
> only way
> to block out EVERYTHING from being displayed if
> $result_deferred_comments is
> empty to use " " around all of the HTML and not exit out of the PHP
> tags?
> Or am I doing something else wrong?
>
> Or, is it a problem with (!empty())?  Since the value is an array,
> will it
> never be parsed as empty even if there is no data retrieved?
>
> Below is my code:
>
> <?php
> $credit_card_id = $_GET['credit_card_id'];
>
> $deferred_comments= "SELECT * FROM comments WHERE credit_card_id =
> '$credit_card_id' AND request_type = 'D'";
> $result_deferred_comments = mssql_query($deferred_comments) or
> die(mssql_error());
>
> if(!empty($result_deferred_comments)) {
> ?>
> <table width="700" border="1" align="center">
>   <tr>
>     <td bgcolor="#FF9900">
> <div align="center"><strong>DEFERRED PAYMENT REQUEST
> COMMENTS</strong></div></td>
>   </tr>
> </table>
> <table width="700" border="0" align="center">
> <?php
> while ($row_deferred_comments =
> mssql_fetch_array($result_deferred_comments)) {
>    $id_deferred_comment = $row_deferred_comments['request_id'];
>    $dateTime_deferred = $row_deferred_comments['comment_date'];
>    $deferred_comments = $row_deferred_comments['comments'];
>    $deferred_wrap_comments = wordwrap($deferred_comments, 60, "<br
> />\n");
> ?>
> <tr>
>     <td width='108' height='13' align='center' bgcolor="#FFD9C6"
> class='tblcell'>
>       <div align='center'><?php echo "$id_deferred_comment"
> ?></div></td>
>     <td width='148' height='13' align='center' bgcolor="#FFD9C6"
> class='tblcell'>
>       <div align='center'><?php echo "$dateTime_deferred"
> ?></div></td>
>     <td width='444' height='13' align='center' bgcolor="#FFD9C6"
> class='tblcell'>
> <div align='left'><?php echo $deferred_wrap_comments; ?></div></td>
> </tr>
> <?php } ?>
> </table>
> <?php } ?>
>
> Thanks,
> Dan
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux