Jump to content

Function/object method


JJC

Recommended Posts

How could I call in formation from a differant table/column in the data base. A member registers and enters data such as phone number and this info is held in users table. Now this member creates an ad and this info is held in the items table. How can I get data from this users "users" table to show ? This is the results page after a search and it shows the users ad with some of the data from the "items" table.


[code]class clsGriditems { //items class @4-DDF99D24

//Variables @4-9DA56C47

    // Public variables
    
    var $Sorter_title;
    var $Sorter_started;
    var $Sorter_location;
    var $Sorter_asking_price;
    var $ComponentName;
    var $Visible; var $Errors;
    var $ds; var $PageSize;
    var $SorterName = "";
    var $SorterDirection = "";
    var $PageNumber;

    var $CCSEvents = "";
    var $CCSEventResult;

    // Grid Controls
    var $StaticControls; var $RowControls;
    var $Navigator;
//End Variables

//Class_Initialize Event @4-9E569F9C

    function clsGriditems()
    {
        global $FileName;
                global $now;

        $this->ComponentName = "items";
        $this->Visible = True;
        $this->Errors = new clsErrors();
        $this->ds = new clsitemsDataSource();
        $this->PageSize = CCGetParam($this->ComponentName . "PageSize", "");
        if(!is_numeric($this->PageSize) || !strlen($this->PageSize))
            $this->PageSize = $now["pagentrys"];
        else
            $this->PageSize = intval($this->PageSize);
        $this->PageNumber = intval(CCGetParam($this->ComponentName . "Page", 1));

        $this->SorterName = CCGetParam("itemsOrder", "");
        $this->SorterDirection = CCGetParam("itemsDir", "");

        $this->bold = new clsControl(ccsLabel, "bold", "bold", ccsInteger, "", CCGetRequestParam("bold", ccsGet));
        $this->bold->HTML = true;
        $this->bold2 = new clsControl(ccsLabel, "bold2", "bold2", ccsText, "", CCGetRequestParam("bold2", ccsGet));
        $this->bold2->HTML = true;
        $this->background = new clsControl(ccsLabel, "background", "background", ccsInteger, "", CCGetRequestParam("background", ccsGet));
        $this->background->HTML = true;
        $this->image_preview = new clsControl(ccsLabel, "image_preview", "image_preview", ccsInteger, "", CCGetRequestParam("image_preview", ccsGet));
                $this->image_preview->HTML = true;
        $this->image_one = new clsControl(ccsLabel, "image_one", "image_one", ccsText, "", CCGetRequestParam("image_one", ccsGet));
                $this->image_one->HTML = true;
        $this->ItemNum = new clsControl(ccsLabel, "ItemNum", "ItemNum", ccsInteger, "", CCGetRequestParam("ItemNum", ccsGet));
        $this->title = new clsControl(ccsLabel, "title", "title", ccsText, "", CCGetRequestParam("title", ccsGet));
        $this->titleb = new clsControl(ccsLabel, "titleb", "titleb", ccsText, "", CCGetRequestParam("titleb", ccsGet));
        $this->keya = new clsControl(ccsLabel, "keya", "keya", ccsInteger, "", CCGetRequestParam("keya", ccsGet));
        $this->keya->HTML = true;
        $this->image_twentyone = new clsControl(ccsLabel, "image_twentyone", "image_twentyone", ccsText, "", CCGetRequestParam("image_twentyone", ccsGet));
        $this->image_twentyone->HTML = true;
        $this->key30 = new clsControl(ccsLabel, "key30", "key30", ccsText, "", CCGetRequestParam("key30", ccsGet));
    $this->key34 = new clsControl(ccsLabel, "key34", "key34", ccsText, "", CCGetRequestParam("key34", ccsGet));
        $this->key35 = new clsControl(ccsLabel, "key35", "key35", ccsText, "", CCGetRequestParam("key35", ccsGet));
        $this->key36 = new clsControl(ccsLabel, "key36", "key36", ccsText, "", CCGetRequestParam("key36", ccsGet));
        $this->key37 = new clsControl(ccsLabel, "key37", "key37", ccsText, "", CCGetRequestParam("key37", ccsGet));
        $this->key38 = new clsControl(ccsLabel, "key38", "key38", ccsText, "", CCGetRequestParam("key38", ccsGet));
        $this->key39 = new clsControl(ccsLabel, "key39", "key39", ccsText, "", CCGetRequestParam("key39", ccsGet));
    
        $this->key1 = new clsControl(ccsLabel, "key1", "key1", ccsText, "", CCGetRequestParam("key1", ccsGet));
        $this->key2 = new clsControl(ccsLabel, "key2", "key2", ccsText, "", CCGetRequestParam("key2", ccsGet));
        $this->key3 = new clsControl(ccsLabel, "key3", "key3", ccsText, "", CCGetRequestParam("key3", ccsGet));
        $this->key4 = new clsControl(ccsLabel, "key4", "key4", ccsText, "", CCGetRequestParam("key4", ccsGet));
        $this->key5 = new clsControl(ccsLabel, "key5", "key5", ccsText, "", CCGetRequestParam("key5", ccsGet));
        $this->key6 = new clsControl(ccsLabel, "key6", "key6", ccsText, "", CCGetRequestParam("key6", ccsGet));
        $this->key7 = new clsControl(ccsLabel, "key7", "key7", ccsText, "", CCGetRequestParam("key7", ccsGet));
        $this->key8 = new clsControl(ccsLabel, "key8", "key8", ccsText, "", CCGetRequestParam("key8", ccsGet));
        $this->key24 = new clsControl(ccsLabel, "key24", "key24", ccsText, "", CCGetRequestParam("key24", ccsGet));
        $this->category = new clsControl(ccsLabel, "category", "category", ccsText, "", CCGetRequestParam("category", ccsGet));
        $this->business_name = new clsControl(ccsLabel, "business_name", "business_name", ccsText, "", CCGetRequestParam("business_name", ccsGet));
        $this->make_offer = new clsControl(ccsLabel, "make_offer", "make_offer", ccsInteger, "", CCGetRequestParam("make_offer", ccsGet));
        $this->make_offer->HTML = true;
        $this->city_town = new clsControl(ccsLabel, "city_town", "city_town", ccsText, "", CCGetRequestParam("city_town", ccsGet));
        $this->state_province = new clsControl(ccsLabel, "state_province", "state_province", ccsText, "", CCGetRequestParam("state_province", ccsGet));
        $this->asking_price = new clsControl(ccsLabel, "asking_price", "asking_price", ccsFloat, Array(False, 2, ".", "", False, "", "", 1, True, ""), CCGetRequestParam("asking_price", ccsGet));
        $this->started = new clsControl(ccsLabel, "started", "started", ccsInteger, "", CCGetRequestParam("started", ccsGet));
        $this->gallerylink = new clsControl(ccsLink, "gallerylink", "gallerylink", ccsText, "", CCGetRequestParam("gallerylink", ccsGet));
        $this->gallerylink->Parameters = CCGetQueryString("QueryString", Array("ccsForm"));
        $this->gallerylink->Page = "gallery.php";
        $this->Sorter_title = new clsSorter($this->ComponentName, "Sorter_title", $FileName);
        $this->Sorter_started = new clsSorter($this->ComponentName, "Sorter_started", $FileName);
        $this->Sorter_asking_price = new clsSorter($this->ComponentName, "Sorter_asking_price", $FileName);
        $this->Sorter_business_name = new clsSorter($this->ComponentName, "Sorter_business_name", $FileName);
        $this->Navigator = new clsNavigator($this->ComponentName, "Navigator", $FileName, 10, tpCentered);
    }
//End Class_Initialize Event



//Initialize Method @4-383CA3E0
    function Initialize()
    {
        if(!$this->Visible) return;

        $this->ds->PageSize = $this->PageSize;
        $this->ds->SetOrder($this->SorterName, $this->SorterDirection);
        $this->ds->AbsolutePage = $this->PageNumber;
    }
//End Initialize Method

//Show Method @4-B28B5156
    function Show()
    {
        global $startpage;
        global $Tpl;
        global $now;
        global $terms;
        if(!$this->Visible) return;

        $ShownRecords = 0;
        $featcount = 0;

        $this->ds->Parameters["urls_title"] = CCGetFromGet("s_title", "");
        $this->ds->Parameters["urls_description"] = CCGetFromGet("s_description", "");
        $this->ds->Parameters["urlShowFeatured"] = CCGetFromGet("ShowFeatured", "");
        if(CCGetFromGet("CatID", "") || $terms["CatID"]){
                $catdb1 = new clsDBNetConnect;
                $catdb1->connect();
                $newSQL1 = "SELECT cat_id FROM categories WHERE sub_cat_id='" . CCGetFromGet("CatID", "") . "'";
                $incat = "'" . CCGetFromGet("CatID", "") . "'";
                if ($terms["CatID"]) {
                    $newSQL1 = "SELECT cat_id FROM categories WHERE sub_cat_id='" . $terms["CatID"] . "'";
                    $incat = "'" . $terms["CatID"] . "'";
                }
                
                $catdb1->query($newSQL1);
                while($catdb1->next_record()){
                        $incat .= " OR category='" . $catdb1->f(0) . "'";
                        $catdb2 = new clsDBNetConnect;
                        $catdb2->connect();
                        $newSQL2 = "SELECT cat_id FROM categories WHERE sub_cat_id='" . $catdb1->f(0) . "'";
                        $catdb2->query($newSQL2);
                        while($catdb2->next_record()){
                                $incat .= " OR category='" . $catdb2->f(0) . "'";
                                $catdb3 = new clsDBNetConnect;
                                $catdb3->connect();
                                $newSQL3 = "SELECT cat_id FROM categories WHERE sub_cat_id='" . $catdb2->f(0) . "'";
                                $catdb3->query($newSQL3);
                                while($catdb3->next_record()){
                                        $incat .= " OR category='" . $catdb3->f(0) . "'";
                                        $catdb4 = new clsDBNetConnect;
                                        $catdb4->connect();
                                        $newSQL4 = "SELECT cat_id FROM categories WHERE sub_cat_id='" . $catdb3->f(0) . "'";
                                        $catdb4->query($newSQL4);
                                        while($catdb4->next_record()){
                                                $incat .= " OR category='" . $catdb4->f(0) . "'";
                                                $catdb5 = new clsDBNetConnect;
                                                $catdb5->connect();
                                                $newSQL5 = "SELECT cat_id FROM categories WHERE sub_cat_id='" . $catdb4->f(0) . "'";
                                                $catdb5->query($newSQL5);
                                                while($catdb5->next_record()){
                                                        $incat .= " OR category='" . $catdb5->f(0) . "'";
                                                }
                                        }
                                }
                        }
                }
                }
                //print $incat;
                $this->ds->Parameters["urlCatID"] = $incat; //CCGetFromGet("CatID", "");
                $this->ds->Parameters["urls_ItemNum"] = CCGetFromGet("s_ItemNum", "");
                if($_GET["s_user_id"]){
                        $userfind = $_GET["s_user_id"];
                        $findDB = new clsDBNetConnect;
                        $GetUser = CCDlookUP("user_id","users","user_login='" . $userfind . "'",$findDB);
                        if($GetUser == NULL){
                                $GetUser = 1000000000000;
                        }
                }
                if(CCGetFromGet("User_ID", "")){
                        $GetUser = CCGetFromGet("User_ID", "");
                }
                $this->ds->Parameters["urls_user_id"] = $GetUser;
        $this->ds->Parameters["urls_asking_min"] = CCGetFromGet("s_asking_min", "");
        $this->ds->Parameters["urls_asking_max"] = CCGetFromGet("s_asking_max", "");
        $this->ds->Parameters["urls_make_offer"] = CCGetFromGet("s_make_offer", "");
        $this->ds->Parameters["urls_quantity"] = CCGetFromGet("s_quantity", "");
        $this->ds->Parameters["urls_city_town"] = CCGetFromGet("s_city_town", "");
        $this->ds->Parameters["urls_state_province"] = CCGetFromGet("s_state_province", "");
        $this->ds->Parameters["urls_category"] = CCGetFromGet("s_category", "");
        //$this->ds->Parameters["urlCatID"] = CCGetFromGet("CatID", "");
        $this->ds->Prepare();
        $this->ds->Open();

        $GridBlock = "Grid " . $this->ComponentName;
        $Tpl->block_path = $GridBlock;
        $uncount = 0;
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShow");

        $is_next_record = $this->ds->next_record();
        if($is_next_record && $ShownRecords < $this->PageSize)
        {
            do {
                    $this->ds->SetValues();
                $Tpl->block_path = $GridBlock . "/Row";

                                $this->image_one->SetValue("");
                                if($this->ds->cat_featured->GetValue() == 1 && ($featcount == 0)) {
                                        $Tpl->SetVar("beginFeat", "<tr><td class=\"feat\" height=\"27\"borderclor=\"#000000\" border=\"1\"  colspan=\"8\">  Featured Ads</td></tr>");
                                        $featcount++;
                                }
                                if($this->ds->cat_featured->GetValue() < 1 && ($featcount == 1)) {
                                        $this->image_one->SetValue("<tr><td class=\"feat\" height=\"27\" borderclor=\"#000000\" border=\"1\" colspan=\"8\">  None Featured ADs—</td></tr>");
                                        $featuredcounter++;
                                        $featcount++;

                                }
                                if($this->ds->cat_featured->GetValue() == 1)
                                {
                                  $uncount++;
                                }
                                if($this->ds->bold->GetValue() == 1){
                                        $this->bold2->SetValue("</b>");
                        $this->bold->SetValue("<b>");
                                } else {
                                        $this->bold2->SetValue("");
                        $this->bold->SetValue("");
                                }
                if($this->ds->background->GetValue() == 1){
                                        $this->background->SetValue("bgcolor=\"#FFFFF0\"");
                                }else{
                                        $this->background->SetValue("bgcolor=\"#FFFFFF\"");
                                }
                                if($this->ds->image_preview->GetValue() == 1 && $this->ds->image_one->GetValue() != ""){
                                    if ($now["has_gd"])
                                        $this->image_preview->SetValue("<table bgcolor=\"#000000\" border=\"1\" width=\"78\" height=\"75\" cellspacing=\"1\" cellpadding=\"0\"><tr><td width=\"75\" height=\"75\" valign=\"middle\" align=\"center\" bgcolor=\"#FFFFFF\"><a href=\"ViewItem.php?ItemNum=" . $this->ds->ItemNum->GetValue() . "\" border=0><img src=\"imageresizer.php?heightsize=150&widthsize=150&filename=". $this->ds->image_one->GetValue()."\" border=0 /></a></td></tr></table>");
                                    else
                                        $this->image_preview->SetValue("<table bgcolor=\"#000000\" border=\"1\" width=\"78\" height=\"75\" cellspacing=\"1\" cellpadding=\"0\"><tr><td width=\"75\" height=\"75\" valign=\"middle\" align=\"center\" bgcolor=\"#FFFFFF\"><a href=\"ViewItem.php?ItemNum=" . $this->ds->ItemNum->GetValue() . "\" border=0>" . thumbnail($this->ds->image_one->GetValue(),150,150,0,0) . "</a></td></tr></table>");
                                } elseif($this->ds->image_one->GetValue() != ""){
                                        $this->image_preview->SetValue("<em><font color=\"#000000\"><strong>Image(s)</strong></font></em>");
                                } else {
                                        $this->image_preview->SetValue("No Image");
                                }
                                $this->ItemNum->SetValue($this->ds->ItemNum->GetValue());
                $this->title->SetValue($this->ds->title->GetValue());
                if($this->ds->make_offer->GetValue() == 1){
                                        $this->make_offer->SetValue("<em><font color=\"#FF0000\"><strong>Best Offer</strong></font></em>");
                                } else {
                                        $this->make_offer->SetValue("");
                                }
                                if($this->ds->city_town->GetValue() != ""){
                        $this->city_town->SetValue($this->ds->city_town->GetValue() . " ");
                } else {
                                        $this->city_town->SetValue($this->ds->city_town->GetValue());
                                }
                                if($this->ds->keya->GetValue() != ""){
                        $this->keya->SetValue ("<font color=\"#ff0000\">M</font><font color=\"#0000ff\">A</font><font color=\"#FF0000\">P</font><font color=\"#0000FF\">Link</font>" );
                                
                                } else {
                                        $this->keya->SetValue("");
                                        }
                                        if($this->ds->image_twentyone->GetValue() != ""){
                        $this->image_twentyone->SetValue($this->ds->image_twentyone->GetValue() . " ");
                                
                                } else {
                                        $this->image_twentyone->SetValue("images/noimage.gif hieght=\"1\" width=\"1\"");
                                        }
                                        
                                $this->state_province->SetValue($this->ds->state_province->GetValue());
                $this->asking_price->SetValue($this->ds->asking_price->GetValue());
                $this->titleb->SetValue($this->ds->titleb->GetValue());
                //$this->keya->SetValue($this->ds->keya->GetValue());
                //$this->image_twentyone->SetValue($this->ds->image_twentyone->GetValue());
                $this->key30->SetValue($this->ds->key30->GetValue());
                $this->key34->SetValue($this->ds->key34->GetValue());
                $this->key35->SetValue($this->ds->key35->GetValue());
                $this->key36->SetValue($this->ds->key36->GetValue());
                $this->key37->SetValue($this->ds->key37->GetValue());
                $this->key38->SetValue($this->ds->key38->GetValue());
                $this->key39->SetValue($this->ds->key39->GetValue());
                $this->key1->SetValue($this->ds->key1->GetValue());
                $this->key2->SetValue($this->ds->key2->GetValue());
                $this->key3->SetValue($this->ds->key3->GetValue());
                $this->key4->SetValue($this->ds->key4->GetValue());
                $this->key5->SetValue($this->ds->key5->GetValue());
                $this->key6->SetValue($this->ds->key6->GetValue());
                $this->key7->SetValue($this->ds->key7->GetValue());
                $this->key8->SetValue($this->ds->key8->GetValue());
                $this->key24->SetValue($this->ds->key24->GetValue());
                $this->category->SetValue($this->ds->category->GetValue());                
                $this->business_name->SetValue($this->ds->business_name->GetValue());
                $theday = getdate($this->ds->started->GetValue());
                                $lastofyear = substr($theday["year"],-2);
                                $enddate = $theday["mon"] . "/" . $theday["mday"] . "/" . $lastofyear;
                                $this->started->SetValue($enddate);
                                unset($newdate);
                                unset($theday);
                                unset($lastofyear);
                                unset($enddate);
                                

                                $jes = mysql_query ("SELECT a.template_var,b.value FROM custom_textarea a,custom_textarea_values b WHERE a.cat_id = {$_GET[CatID]} AND b.field_id = a.id AND b.ItemNum = ".$this->ds->ItemNum->GetValue());
                if (@mysql_num_rows($jes))
                while ($data = @mysql_fetch_row($jes))
                   {
                $this->jimkey_custom = new clsControl(ccsLabel, $data[0], $data[0], ccsText, "", CCGetRequestParam($data[0], ccsGet));
                $this -> jimkey_custom  -> SetValue($data[1]);
                $this -> jimkey_custom  -> Show();
                   }
                $jes = @mysql_query ("SELECT a.template_var,b.value FROM custom_textbox a,custom_textbox_values b WHERE a.cat_id = {$_GET[CatID]} AND b.field_id = a.id AND b.ItemNum = ".$this->ds->ItemNum->GetValue());

                if (@mysql_num_rows($jes))
                while ($data = @mysql_fetch_row($jes))
                   {
                $this->jimkey_custom = new clsControl(ccsLabel, $data[0], $data[0], ccsText, "", CCGetRequestParam($data[0], ccsGet));
                $this -> jimkey_custom  -> SetValue($data[1]);
                $this -> jimkey_custom  -> Show();
                   }

                $jes = mysql_query ("SELECT a.template_var,c.option as value FROM custom_dropdown a,custom_dropdown_values b,custom_dropdown_options c
                                       WHERE a.cat_id = {$_GET[CatID]} AND b.field_id = a.id AND b.option_id = c.id  AND b.ItemNum = ".$this->ds->ItemNum->GetValue());
                if (@mysql_num_rows($jes))
                while ($data = @mysql_fetch_row($jes))
                   {
                $this->jimkey_custom = new clsControl(ccsLabel, $data[0], $data[0], ccsText, "", CCGetRequestParam($data[0], ccsGet));
                $this -> jimkey_custom  -> SetValue($data[1]);
                $this -> jimkey_custom  -> Show();
                }


                $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShowRow");
                $this->bold->Show();
                $this->bold2->Show();
                $this->background->Show();
                $this->image_preview->Show();
                                $this->image_one->Show();
                $this->ItemNum->Show();
                $this->title->Show();
                $this->titleb->Show();
                $this->keya->Show();
                $this->image_twentyone->Show();
                $this->key30->Show();
                $this->key34->Show();
                $this->key35->Show();
                $this->key36->Show();
                $this->key37->Show();
                $this->key38->Show();
                $this->key39->Show();
                $this->key1->Show();
                $this->key2->Show();
                $this->key3->Show();
                $this->key4->Show();
                $this->key5->Show();
                $this->key6->Show();
                $this-
Link to comment
Share on other sites

I'll take your word for it that something in that mass of code is relevant to your question, but I'm certainly not going to look for it.

The answer is to use a JOIN on the two tables.

see [a href=\"http://www.w3schools.com/sql/sql_join.asp\" target=\"_blank\"]http://www.w3schools.com/sql/sql_join.asp[/a]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.