How do I skip an item in while loop if variable empty? How do I skip an item in while loop if variable empty? sql sql

How do I skip an item in while loop if variable empty?


You can use continue control structure for skip an iteration. Please read the docs

Example:

if(!$row['tweet']) {  continue;}


You could also not return rows without information in tweet1, this would make the php check for data in tweet1 unnecessary.

$query = mysql_query("SELECT * FROM $DBtable WHERE tweet1 IS NOT NULL ORDER BY time");


if (empty($row['tweet'])) {    continue;}