az_wraith Posted May 11, 2007 Share Posted May 11, 2007 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 More sharing options...
justsomeguy Posted May 11, 2007 Share Posted May 11, 2007 How are seasons and divisions related in the database? Link to comment Share on other sites More sharing options...
az_wraith Posted May 11, 2007 Author Share Posted May 11, 2007 How are seasons and divisions related in the database?In the seasons table I have seaid, seaname. And in the divisions table I have divid, divname, divseaid. divseaid is the seaid. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 11, 2007 Share Posted May 11, 2007 So then when you deactivate the season you will also want to deactive the division where divseaid equals the season ID. Link to comment Share on other sites More sharing options...
az_wraith Posted May 11, 2007 Author Share Posted May 11, 2007 Correct Link to comment Share on other sites More sharing options...
justsomeguy Posted May 12, 2007 Share Posted May 12, 2007 You can add this line to the end of the active_s function:active_d($cid, $active_sea, $option); Link to comment Share on other sites More sharing options...
az_wraith Posted May 14, 2007 Author Share Posted May 14, 2007 Thanks Justsomeguy I will have to give it a try when I get a chance. I was also thinking that I could also use the `where` statement in database connection to not show division if season is disabled. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.