MyBB Community Forums

Full Version: switch statment
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Can someone write a small working switch statement that MyBB uses?
If I can see the script in it's simplest form then I can more easily comprehend it.
switch($action)
{
case "news":
echo "news";
break;
case "Mozilla":
echo "firefox";
break;
default:
echo "index";
break;
}

then use a url like http://www.site.com/index.php?action=news or whatever you want.
Thanks k776 I'll work with it now.

Edit:
What query loops through the table and display all the users?


Well I have played around with it and now have a better grasp of the switch statement.
http://harmor.zeeblo.com/mybb/page.php
well, you could use this
$query = $db->query("SELECT uid,username,email,hidemail FROM ".TABLE_PREFIX."users");
while($user = $db->fetch_array($query))
{
echo "<a href=\"member.php?action=profile&amp;uid=".$user['uid']."\">".$user['username']."</a>";
if($user['hideemail'] != "yes")
{
echo " (<a href=\"mailto:".$user['email']."\">".$user['email']."</a>)";
}
else
{
echo "";
}
}
That will loop through all members and link to their profile and show their email if they havev't requested it to be hidden. If you want me to intergrate you switch script, feel free to post it here and I'll take a look, optimize and and re post it Big Grin
You need

Notice the dot after the $profile.
$query = $db->query("SELECT uid,username,email,hideemail FROM ".TABLE_PREFIX."users");
while($user = $db->fetch_array($query))
{
$profile .= "<a href=\"member.php?action=profile&amp;uid=".$user['uid']."\">".$user['username']."</a><br />";
/*if($user['hideemail'] != "yes")
{
$mailto = " (<a href=\"mailto:".$user['email']."\">".$user['email']."</a>)";
}
else
{
$mailto = "";
} */
}

eval("\$user_page = \"".$templates->get("user_page")."\";");
outputpage($user_page);


http://harmor.zeeblo.com/mybb/page.php?action=usernames
You could use something more advanced like this
$query = $db->query("SELECT uid,username,email,hideemail,postnum FROM ".TABLE_PREFIX."users");
while($user = $db->fetch_array($query))
{
    if($user['hideemail'] != "yes")
    {
        $mailto = " <a href=\"mailto:".$user['email']."\">".$user['email']."</a> |";
    }
    else
    {
        $mailto = "";
    }
    $profile .= "<a href=\"member.php?action=profile&amp;uid=".$user['uid']."\">".$user['username']."</a>(Posts: ".$user['postnmum']." |$mailto <a href=\"private.php?action=send&uid=".$user['uid']."\">PM User</a>)<br />";
}

eval("\$user_page = \"".$templates->get("user_page")."\";");
outputpage($user_page);
thanks k776.

I've been looking at this mod (i thinnk it's for links)
Well I've been trying to duplicate the code for the admin panel.
I should be done with that soon. Then my custom page mod will be released.
I hope no one beats me to it.