I have an array that is created in a WHILE loop (fetches values from the database, assigns, then generates a simple UL. On the rare occasions that the UL has an empty LI, I would like for it to simply generate “nothing” (something like white-space or whatever).
In order to do this, I believe I’ll have to check for empty values in the array during the iterations. How would I do this exactly?
Below is the code I’m working with and I welcome input on how to improve what I have thus far:
function fs_chart(){
$chart[] = '';
$result = mysql_query("SELECT * FROM fs_members");
$count = mysql_num_rows($result);
$i=0;
while($row = mysql_fetch_array($result)){
//if(in_array('',$row)){echo $row[];}//Create condition logic to handle empty array values...
if($i % 2){$class[] = 'even';}else{$class[] = 'odd';}
$chart[] = '<ul class="inline '.$class[$i].'">
<li><a href="#" title="'.$row['first_name'].'">'.$row['first_name'].'</a></li>
<li><a href="#" title="'.$row['middle_name'].'">'.$row['middle_name'].'</a></li>
<li><a href="#" title="'.$row['last_name'].'">'.$row['last_name'].'</a></li>
<li><a href="#" title="'.$row['department'].'">'.$row['department'].'</a></li>
<li><a href="#" title="'.$row['office_phone_number'].'">'.$row['office_phone_number'].'</a></li>
<li><a href="#" title="'.$row['office_room_number'].'">'.$row['office_room_number'].'</a></li>
<li><a href="#" title="'.$row['membership_length'].'">'.$row['membership_length'].'</a></li>
<li><a href="#" title="'.$row['university_tenure'].'">'.$row['university_tenure'].'</a></li>
<li><a href="#" title="Delete">Delete</a></li>
</ul>';
$i++;
}
foreach($chart as $value){echo $value;}
}
I know there’s a lot of room for improvement here, so again, I welcome any suggestions.