Hi guys.
Does anyone know if it's possible to use the switch/case function in the middle of a loop to automatically generate the cases? I've created the following page but it doesn't seem to be working and I can't figure out what's wrong with it:
<?
//connect to the database
include ("db_connect.php");
//count how many mods there are to control how many switch statements we need.
$sql_mods_check = mysql_query("SELECT * FROM tbl_users WHERE mod='1'");
$mod_check = mysql_num_rows($sql_mods_check);
//select all records for MODS and generate case/switch statements based on the number created above.
$authors = "SELECT * FROM tbl_users where mod='1'";
$resultauthor = mysql_query($authors);
while ($row = mysql_fetch_assoc($resultauthor))
{
foreach ($row as $field=>$value)
{
if ($field == user_id)
{
$user_id = $value;
}
else if ($field == username)
{
$username = $value;
}
}
switch ($author)
{
for ( $i = 0; $i <= $mod_check; $i++ )
{
case $user_id:
$author=$username;
break;
}
}
}
?>
The error I'm getting is:
Parse error: parse error, unexpected T_FOR, expecting T_CASE or T_DEFAULT or '}' in /home/hqxxyucx/public_html/test_modcount.php on line 29