Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- <?php
- class Category {
- public $Ccategory;
- private $EndOfStatement;
- private $Assembled_Array = array();
- function __construct ($category_ident = null) {
- if ((!isset($category_ident)) || (!is_string($category_ident))) {
- $finish = 'LIMIT 30';
- } else {
- $finish = "WHERE `C_CT_Name`='".$category_ident."' LIMIT 1";
- }
- $this->EndOfStatement = $finish;
- }
- function assemble () {
- $DB = new DB_Func();
- $Con = $DB->connect();
- $QUERY = "SELECT `C_CID`, `C_CT_Name`, `C_CT_Num_Subs` FROM `c_categories_main` ".$this->EndOfStatement;
- $toQuery = mysql_query($QUERY, $Con) or die (mysql_error());
- if ((mysql_num_rows($toQuery) == 0) || (mysql_num_rows($toQuery) > 30)) {
- return 0;
- } else {
- $count = mysql_num_rows($toQuery);
- $Assemble = array();
- $Filled = array();
- $row = 1;
- for ($i = 0; $i < $count; $i++) {
- mysql_data_seek($toQuery,$i);
- $fQuery = mysql_fetch_assoc($toQuery);
- $HowMany = $fQuery['C_CT_Num_Subs'];
- $Value = "`c_categories_".$fQuery['C_CID']."_subcategories`";
- $Key = $fQuery['C_CT_Name'];
- $Assemble = array ("CatName" => $Key , "Location" => $Value, "NumSubs" => $HowMany);
- $Filled = array_fill(0,$row,$Assemble);
- }
- $this->Assembled_Array = $Filled;
- return $this->Assembled_Array;
- }
- }
- }
- include ("category_class.php");
- $Category = new Category("Home Services");
- $Display = $Category->assemble();
- print ("\r\n");
- print (var_dump($Display));
- ?>
- Outputs:
- array(2) {
- [0]=> array(3)
- {
- ["CatName"]=> string(13) "Home Services"
- ["Location"]=> string(39) "`c_categories_0000000002_subcategories`"
- ["NumSubs"]=> string(2) "01"
- }
- [1]=> array(3)
- {
- ["CatName"]=> string(13) "Home Services"
- ["Location"]=> string(39) "`c_categories_0000000002_subcategories`"
- ["NumSubs"]=> string(2) "01"
- }
- }
Add Comment
Please, Sign In to add comment