Results 1 to 9 of 9

Thread: Need some help with this query.

  1. #1
    Join Date
    Aug 2001
    Location
    Toronto, Ontario
    Posts
    678

    Default Need some help with this query.

    I have a query that I just can't seem to figure out.

    I want to select links from the same category that link is in.

    query = "select * from idx_link where category_id = (to same category that link is in) order by title";

  2. #2
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    Code:
    $query = "SELECT * from  idx_link where link_id = $link_id";
    $result = $conn->Execute($query);
    
    $category_id = $result->Fields("category_id");
    
    query = "select * from idx_link where category_id = $category_id order by title";
    $result = $conn->Execute($query);



    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  3. #3
    Join Date
    Aug 2001
    Location
    Toronto, Ontario
    Posts
    678

    Default

    Fatal error: Call to a member function on a non-object on:

    $category_id = $result->Fields("category_id");

    I'm basically trying to insert this query into the detail.php page.


    Where am I going wrong?

  4. #4
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    try changing $link_id to $linkid



    Last edited by esm; 10-05-2004 at 07:20 PM.
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  5. #5
    Join Date
    Aug 2001
    Location
    Toronto, Ontario
    Posts
    678

    Default

    its not the $linkid or $id which I have tried.

    For some reason it get an error on that one important line

    $category_id = $result->Fields("category_id"); which prevents me from isolating the category_id

    why oh why...

    When i put $category_id = 200; it works for category 200... but thats not what i want... boo

  6. #6
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    send me your detail.php file



    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  7. #7
    Join Date
    Aug 2001
    Location
    Toronto, Ontario
    Posts
    678

    Default

    OK. I fixed it.

    $result1 = $conn->Execute($query);

    $category_id = $result1->Fields("category_id");

    All i had to do was place a 1 after the result...

  8. #8
    Join Date
    Jul 2003
    Posts
    20

    Default Shouldn't something be pass to $result first

    Shouldn't something be pass to $result first before trying to extract something from it

  9. #9
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    here is the code to make it work:

    Code:
        ///hot links hack ******************
       $hot_links_obj = new clsLink;
       $hot_links_obj->InitDB($dbServer,$dbHostname,$dbUsername,$dbPassword,$dbName);
       $hot_links_obj->table_name = "idx_link";
       $hot_links_obj->category_table_name = "idx_category";  
       $hot_links_obj->max_rows = $main_hot_links;
      
      $queryh = "select * from idx_link where link_id = '$id'";
      $resulth = $conn->Execute($queryh);
    
      $category_id = $resulth->Fields("category_id");
      
      $hot_links_obj->queryh1 = "select * from idx_link where category_id = $category_id order by title";
      $hot_links_obj->resulth1 = $conn->Execute($queryh1);
      
      $hot_links_obj->template = $msg["99999"];
      
      $hot_links_obj->enable_cache = false;
      $hot_links = $hot_links_obj->Display();  
    
      ///hot links end **********************


    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

Similar Threads

  1. Replies: 6
    Last Post: 09-11-2003, 08:00 AM
  2. indexu 3.1 & mysql 3.22
    By Heiko in forum v5.x
    Replies: 26
    Last Post: 07-07-2003, 04:30 PM
  3. All fields in all templates ??
    By Frank71 in forum v5.x
    Replies: 8
    Last Post: 06-25-2003, 08:27 PM
  4. Query Box
    By craven in forum v5.x
    Replies: 5
    Last Post: 04-28-2003, 08:14 PM
  5. kill all links?
    By kwilder in forum v5.x
    Replies: 5
    Last Post: 07-16-2002, 03:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •