Reputation: 199
I am trying to put together a little script just to identify which rows of my table are empty, the code I am using is below, the problem it returns rows that are empty and full.
Any suggestions would be appreciated.
$query = "SELECT ip_start_range, id FROM blocklistip";
$result = mysql_query( $query );
while( $row = mysql_fetch_assoc( $result ) ) {
if(isset($row['ip_start_range'])) { ?><br /><br /><?php
echo $row['id']; ?><br /><br /><?php
} else {
echo '<p>" No Result "</p>';
}
}
Upvotes: 0
Views: 43
Reputation: 11393
Your code does not work as you want because $row['ip_start_range']
is always set, since you fetch it from query results.
Instead, filter the records with a WHERE
condition:
$query = "SELECT ip_start_range, id FROM blocklistip WHERE ip_start_range IS NULL";
Or, if the field ip_start_range
does not allow NULL, you can filter by empty strings:
$query = "SELECT ip_start_range, id FROM blocklistip WHERE ip_start_range=''";
Upvotes: 1