Jump to content

Foreach


zackcez

Recommended Posts

Here's my code:

foreach ($skillNames as $skill) {
$q = "SELECT * FROM user ORDER BY ".$skill."xp DESC LIMIT 1";  
$r = mysql_query($q) or die(mysql_error());
while($row = mysql_fetch_array($r)){
	$perms = getPerms($row['usergroupid']);
	if ($perms == '1' || $perms == '0') {
		$pre       = getPre($row['usergroupid']);
		$suf       = getSuf($row['usergroupid']);
		$usernamer = $pre."".$row['username']."".$suf;
		echo"<tr><td class=\"alt1\" align=\"center\" nowrap=\"nowrap\">"; // "Layout"
		echo"<img src=\"http://rshelp.net/modules/highscores/icons/".$skill.".gif\"></td>"; //Image
		echo"<td class=\"alt1\" nowrap=\"nowrap\"><a href=\"index.php?pageid=highscores&action=user&user=" . $row['username'] . "\">$usernamer</a> (" . $row[''.$skill.'lvl'] . ")</td></tr>"; //User Info
	}
}
unset($q);
unset($r);
}

Everything is correctly defined...lets say the person the query selects first doesn't have the right permissions, it then echo's nothing....how could i make it so if it returns without anything that it 'continues down the line'

Link to comment
https://forums.phpfreaks.com/topic/117799-foreach/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.