Jump to content

Combine Functions


az_wraith
 Share

Recommended Posts

First off I would like to say thanks for all the help others on this site have helped me with.I have a seasons and divisions page where I can activate and deactivate a certain season and division. What I am trying to do is, when I deactivate a season it will also deactivate the division that is associated with it. Below is the functions to activate and deactivate for seasons and divisions.seasons function:

function active_s( $cid=null, $active_sea=1, $option ) {    global $database;        if (!is_array( $cid ) || count( $cid ) < 1) {            $action = $active_sea ? 'activesea' : 'inactivesea';            echo "<script> alert('Select an item to $action'); window.history.go(-1);</script>\n"; exit; }        mosArrayToInts( $cid );        $cids[] = 'se.sid=' . implode( ' OR se.sid=', $cid );        $query = "UPDATE seasons AS se"            . "\n SET se.s_active = " . intval( $active_sea )            .(count( $cids ) ? "\nWHERE "             . implode( ' AND ', $cids ) : "");        $database->setQuery( $query );        if (!$database->query()) {            echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; exit(); }    mosRedirect("index.php?option=$option&task=seas");}

division function:

function active_d( $cid=null, $active_div=1, $option ) {    global $database;        if (!is_array( $cid ) || count( $cid ) < 1) {            $action = $active_div ? 'activediv' : 'inactivediv';            echo "<script> alert('Select an item to $action'); window.history.go(-1);</script>\n"; exit; }        mosArrayToInts( $cid );        $cids = 'di.divid=' . implode( ' OR di.divid=', $cid );        $query = "UPDATE divisions AS di"            . "\n SET di.d_active = " . intval( $active_div )            . "\n WHERE ( $cids )" ;        $database->setQuery( $query );        if (!$database->query()) {            echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; exit(); }	mosRedirect("index.php?option=$option&task=divs");}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...