while($row = mysql_fetch_assoc($recordsetName)) {
if($row['fieldname'] != '') {
echo '<li><a href="#">Content Goes Here</a></li>';
}
}
or you could check if the query was successful...
$result = mysql_query($sql);
if($result) {
echo '<li><a href="#">Content Goes Here</a></li>';
}
or if it returned any results...
$results = mysql_fetch_assoc($recordsetName);
if(mysql_num_rows($results) > 0) {
while($row = mysql_fetch_assoc($results)) {
echo '<li><a href="#">Content Goes Here</a></li>';
}
}
Also, you should really be using mysqli
or PDO
, as mysql
is depreciated.
Edit: added loop in example 3.