Jump to content

Combine Functions


az_wraith

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

Archived

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

×
×
  • Create New...