ballhogjoni Posted July 23, 2008 Share Posted July 23, 2008 I have the below code and I want to change the specific variables based on the if else clause. How would I do this? It seems like the code below won't work and I can't add the if else in the class unless its in a function. if($_GET['ac'] == 'Areas'){ $table_name = 'Area'; $table_id = 'area_id'; $col = array( 'area_id' => array( 'type' => 'int', 'size' => 11, 'qf_type' => 'hidden' ), 'area' => array( 'type' => 'varchar', 'size' => 255, //form element definition 'require' => true ), 'page' => array( 'type' => 'varchar', 'size' => 255, 'require' => true, 'qf_vals' => array( 'hotels' => 'Hotels', 'clubs' => 'Clubs', 'shows' => 'Shows', 'dining' => 'Dining', 'tours' => 'Tours', 'golf' => 'Golf' ) ) ); }else{ $table_name = 'Categories'; $table_id = 'category_id'; $col = array( 'category_id' => array( 'type' => 'int', 'size' => 11, 'qf_type' => 'hidden' ), 'category_name' => array( 'type' => 'varchar', 'size' => 255, //form element definition 'require' => true ), 'page' => array( 'type' => 'varchar', 'size' => 255, 'require' => true, 'qf_vals' => array( 'shows' => 'Shows', 'clubs' => 'Clubs', 'hotels' => 'Hotels', 'dining' => 'Dining', 'tours' => 'Tours', 'golf' => 'Golf' ) ) ); } /** * * Hotel * * This is the top level for path hierarchey * * @subpackage SubPackage * @see FR_Object_DB_Table */ class Category extends FR_Object_DB_Table { /** * Table name * @var mixed * @access public */ var $table_name; /** * Hotel id field * @var mixed * @access public */ var $table_id; Link to comment https://forums.phpfreaks.com/topic/116289-how-to-change-variable-in-a-class-from-outside-the-class/ Share on other sites More sharing options...
cooldude832 Posted July 23, 2008 Share Posted July 23, 2008 Example <?php class fish{ Public Var $type = "Bluegil"; } $fish = new fish; if($_get['species'] == 1){ $fish->type = "Bass"; } ?> Link to comment https://forums.phpfreaks.com/topic/116289-how-to-change-variable-in-a-class-from-outside-the-class/#findComment-597958 Share on other sites More sharing options...
ballhogjoni Posted July 23, 2008 Author Share Posted July 23, 2008 Thanks for the answer but I don't see how that works in the situation I have. Basically if $_GET['ac'] == 'Areas' then I need the variables to equal what they are assigned to in the if statement. Link to comment https://forums.phpfreaks.com/topic/116289-how-to-change-variable-in-a-class-from-outside-the-class/#findComment-597971 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.