# PHP check for empty results in while loop

**URL:** <https://forum.kirupa.com/t/php-check-for-empty-results-in-while-loop/108216>\
**Category:** Uncategorized\
**Created:** [April 22, 2004, 5:50pm UTC](https://forum.kirupa.com/t/php-check-for-empty-results-in-while-loop/108216 "2004-04-22T17:50:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![imagined](https://avatars.discourse-cdn.com/v4/letter/i/a87d85/32.png) [@imagined](https://forum.kirupa.com/u/imagined)\
**Post date:** [April 22, 2004, 5:50pm UTC](https://forum.kirupa.com/t/php-check-for-empty-results-in-while-loop/108216/1 "2004-04-22T17:50:29Z")

</div>

I have this WHILE loop:

$sql = “SELECT \* FROM supImages WHERE deleted = ‘no’”;  
$result = mysql\_db\_query(‘uisd’, $sql) or die(“Couldn’t get file list”);

```
while($row = mysql_fetch_array($result))
{
	$data = ($row["data"]);
                    echo $data;
         }

```

In the database if there is rows set DELETED = ‘no’, ECHO $DATA will show something, and thats good. Now, what if there is no DELETED = ‘yes’. What if all the rows for column DELETED are set to YES. Then $data would be empty.

I want to make an IF statement to display “There is no files” in case all DELETED are set to YES. THis is what I did, but doesnt work:

```
	if(empty($data))
	{
	echo ('&lt;p&gt;There is no images to display.&lt;/p&gt;');
	echo ('&lt;a href="process.php?id=$id&gt;Click here to add pictures&lt;/a&gt;');
	}

```

Any suggestions?
