1.

Solve : PHP Action Array?

Answer»

How do you use, or set up an action array like in this forum?
I want to use something like this: "help.php?id=blablabla".

Thanks for any help.it's easy to set one up. You can just create a link on the webpage with the "help.php?id=blablabla"
To retrieve it, use the $_REQUEST VARIABLE
http://docs.php.net/manual/en/reserved.variables.request.php
http://docs.php.net/manual/en/language.variables.external.phpCode: [Select] $actionArray = array(
'activate' => array('Register.php', 'Activate'),
'admin' => array('Admin.php', 'Admin'),
'announce' => array('Post.php', 'AnnounceTopic'),
'ban' => array('ManageBans.php', 'Ban'),
'boardrecount' => array('Admin.php', 'AdminBoardRecount'),
'buddy' => array('Subs-Members.php', 'BuddyListToggle'),
'calendar' => array('Calendar.php', 'CalendarMain'),
'cleanperms' => array('Admin.php', 'CleanupPermissions'),
'collapse' => array('Subs-Boards.php', 'CollapseCategory'),
// + about 50 more...
);

// Get the function and file to include - if it's not there, do the board index.
if (!isset($_REQUEST['action']) || !isset($actionArray[$_REQUEST['action']]))
{
// Catch the action with the theme?
if (!empty($settings['catch_action']))
{
require_once($sourcedir . '/Themes.php');
return 'WrapAction';
}

// Fall through to the board index then...
require_once($sourcedir . '/BoardIndex.php');
return 'BoardIndex';
}

// Otherwise, it was set - so let's go to that action.
require_once($sourcedir . '/' . $actionArray[$_REQUEST['action']][0]);
return $actionArray[$_REQUEST['action']][1];

This is the SMF code for the actions. I thought it might be complicated like that.Will you show me how to use this variable? I'm QUITE new to PHP.Here's an example. It may and it may not work, but it's the GENERAL idea. I recommend buying a book about php/mysql. That will help you a lot more than the common method of trying to wade through thousands of useless online tutorials.

Code: [Select] <?php
if($_REQUEST['urlvariable']=='page1')//entercodetogotopage1
elseif($_REQUEST['urlvariable']=='page2')//entercodetogotopage2
else//entercodetogotodefaultpage
?>
I was THINKING about buying a book but they're expensive - about €50, or about $80. That's in Ireland anyway - but everything is expensive here.

Thanks for your time and help.have you checked your LOCAL library? No I havent because I dont actually have a local library. I live in the country.

There is one in our nearest town, but its very small.

Just have to rely on CH....



Discussion

No Comment Found