SitePoint Sponsor

User Tag List

Results 1 to 17 of 17

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    i can't get account id

    Hello i am trying here to get account id but i cant get it i don't know where is the problem please help me
    PHP Code:
    <?php
    /* load system lib */
    require_once( RL_LIBS 'system.lib.php' );

    /* redefine page path */
    $page_info['Path'] = $pages['browse'];

    $period = empty($_GET['nvar_1']) ? $_GET['period'] : $_GET['nvar_1'];

    $type = empty($_GET['type']) ? 'sale_rent' $_GET['type'];
    //$disp_type = empty($_GET['type']) ? 'listings' : $_GET['type'];
    $period = empty($period) ? 'new' $period;

    /* redefine page name/title */
    $bread_crumbs[1]['name'] = $lang['new_'$disp_type];
    $bread_crumbs[1]['title'] = $lang['new_listings'];
    $page_info['name'] = $lang['new_'$disp_type];

    if ( 
    $period == 'today' )
    {
        
    $page_info['name'] = $lang['today_'$disp_type];
        
    $bread_crumbs[] = array(
            
    'name' => $lang['today_listings'],
            
    'title' => $lang['today_'$disp_type]
        );
        if ( !empty(
    $_GET['type']) )
        {
            
    $bread_crumbs[1]['vars'] .= "type=" $_GET['type'];
        }
    }

    if ( 
    array_key_exists($type$l_listing_types) )
    {
        
    /* fields for sorting */
        
    $sorting = array(
            
    'category' => array(
                
    'phrase' => $lang['category'],
                
    'field' => 'Kind_ID'
            
    ),
            
    'date' => array(
                
    'phrase' => $lang['date'],
                
    'field' => 'Pay_date'
            
    )
        );
        
    $rlSmarty -> assign_by_ref'sorting'$sorting );
        
        
    /* define sort field */
        
    $sort_by = empty($_GET['sort_by']) ? $_SESSION['ml_sort_by'] : $_GET['sort_by'];
        if ( !empty(
    $sorting[$sort_by]) )
        {
            
    $order_field $sorting[$sort_by]['field'];
        }
        
    $_SESSION['ml_sort_by'] = $sort_by;
        
    $rlSmarty -> assign_by_ref'sort_by'$sort_by );
        
        
    /* define sort type */
        
    $sort_type = empty($_GET['sort_type']) ? $_SESSION['ml_sort_type'] : $_GET['sort_type'] ;
        
    $sort_type in_array$sort_type, array('asc''desc') ) ? $sort_type false ;
        
    $_SESSION['ml_sort_type'] = $sort_type;
        
    $rlSmarty -> assign_by_ref'sort_type'$sort_type );
        
        
    /* get listings */
        
    $reefless -> loadClass('Listings');
        
        
    $pInfo['current'] = (int)$_GET['pg'];

        if ( 
    $pInfo['current'] > )
        {
            
    $bc_page str_replace('{page}'$pInfo['current'], $lang['title_page_part']);
            
            
    /* add bread crumbs item */
            
    $bread_crumbs[1]['title'] .= $bc_page;
        }

        
    $listings $rlListings -> getListingsByAccount($account_id$order_field$sort_type$pInfo['current'], $config['listings_per_page']);
        
    $rlSmarty -> assign_by_ref('listings'$listings);
        
        
    /* get current account */

        
    $account_info $rlAccount -> getAccountInfo$_SESSION['id'] );
        
    $rlSmarty -> assign_by_ref'aInfo'$account_info );
        

        
    /* get dealer accounts */
        
    if ($config['mod_rewrite'])
        {
            
    $var $_GET['nvar_1'];

            
    preg_match'/(.*)-d([0-9]+)/'$var$id );
            
    $dealer_id = (int)$id[2];
        }
        else
        {
            
    $dealer_id = (int)$_GET['id'];
        }
        
        
    $dealer_id $listings['Account_ID'];
        
    $dealer $rlAccount -> getDealerInfo($dealer_id);
        
    $rlSmarty -> assign_by_ref('dealer'$dealer);


        
    /* get seller information */
        /*$start = $start > 1 ? ($start - 1) * $limit : 0;
        $seller_id = $listings[$start]['Account_ID'];
        $seller_info = $rlAccount -> getProfileInfo( $seller_id );
        $rlSmarty -> assign_by_ref( 'seller_info', $seller_info );*/
        
        
        
    if ( $seller_info['Account_type'] == 'dealer' )
        {
            
    $dealer_path = (!empty($seller_info['First_name']) || !empty($seller_info['Last_name'])) ? $seller_info['First_name'].' '.$seller_info['Last_name'] : $seller_info['Username'];
            
    $dealer_path $rlSmarty -> str2path($dealer_path) . '-d' $seller_info['ID'];
            
    $rlSmarty -> assign_by_ref'dealer_path'$dealer_path );
            
            
    $sql "SELECT COUNT(`T1`.`ID`) AS `count` FROM `" RL_DBPREFIX "listings` AS `T1` ";
            
    $sql .= "LEFT JOIN `" RL_DBPREFIX "categories` AS `T2` ON `T1`.`Kind_ID` = `T2`.`ID` ";
            
    $sql .= "LEFT JOIN `" RL_DBPREFIX "listing_plans` AS `T3` ON `T1`.`Plan_ID` = `T3`.`ID` ";
            
    $sql .= "WHERE `T1`.`Account_ID` = '{$seller_info['ID']}' AND `T1`.`Status` = 'active' AND `T2`.`Type` <> 'advertising'";
            
    $sql .= "AND UNIX_TIMESTAMP(DATE_ADD(`T1`.`Pay_date`, INTERVAL `T3`.`Days` DAY)) > UNIX_TIMESTAMP(NOW()) ";
            
    $listing_count $rlDb -> getRow($sql);
            
    $seller_info['listings'] = $listing_count['count'];
        }

        
    /* get additional account fields */
        
    $additional $rlAccount -> getAdditional$seller_id );
        
    $additional['ID'] = $seller_id;
        
    $additional_fields $rlAccount -> getAccountFields$seller_info['Type_ID'], 'display'$additional);
        
    $rlSmarty -> assign_by_ref'additional_fields'$additional_fields );
        
        
    $reefless -> loadClass'Message' );
        
        if ( !empty(
    $listings) )
        {
        
            
    /* build rss */
            /*$rss['item'] = 'listings';
            if ($type != 'sale_rent')
                $rss['type'] = $type;
            if ($period != 'new')
                $rss['period'] = $period;
            $rss['title'] = $category['name'];
            $rlSmarty -> assign_by_ref( 'rss', $rss );
            
            /* enable print page */
            /*$print['item'] = 'listings';
            if ($type != 'sale_rent')
                $print['type'] = $type;
            if ($period != 'new')
                $print['period'] = $period;

            $rlSmarty -> assign_by_ref('print', $print);*/
        
    }
        
        
    $pInfo['calc'] = $rlListings -> calc;
        
    $rlSmarty -> assign_by_ref'pInfo'$pInfo );
        
        
    /* register ajax methods */
        
    $rlXajax -> registerFunction( array( 'addToFavorite'$rlListings'ajaxAddToFavorite' ) );
        if ( 
    defined('IS_LOGIN') )
        {
            
    $rlXajax -> registerFunction( array( 'restoreFavorite'$rlListings'ajaxRestoreFavorite' ) );
        }
        
        
    $rlHook -> load('listingsBottom');
    }
    else
    {
        
    $sError true;
    }

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,401
    Mentioned
    147 Post(s)
    Tagged
    4 Thread(s)
    You're doing loads of stuff in that code. Where exactly are you trying to get the account id?

  3. #3
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello guido, here i am trying

    PHP Code:
        $dealer_id $listings['Account_ID'];
        
    $dealer $rlAccount -> getDealerInfo($dealer_id);
        
    $rlSmarty -> assign_by_ref('dealer'$dealer); 
    its not work for me because there is $key for each listing and i cant get it and if i type like this

    PHP Code:
        $dealer_id $listings[0]['Account_ID'];
        
    $dealer $rlAccount -> getDealerInfo($dealer_id);
        
    $rlSmarty -> assign_by_ref('dealer'$dealer); 
    its give first account id for listing 0, i hope u understand me

  4. #4
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,401
    Mentioned
    147 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by jone kent View Post
    Hello guido, here i am trying

    PHP Code:
        $dealer_id $listings['Account_ID'];
        
    $dealer $rlAccount -> getDealerInfo($dealer_id);
        
    $rlSmarty -> assign_by_ref('dealer'$dealer); 
    its not work for me because there is $key for each listing and i cant get it and if i type like this

    PHP Code:
        $dealer_id $listings[0]['Account_ID'];
        
    $dealer $rlAccount -> getDealerInfo($dealer_id);
        
    $rlSmarty -> assign_by_ref('dealer'$dealer); 
    its give first account id for listing 0, i hope u understand me
    Yes I think I understand. But why is that first account id for listing 0 not ok? What account id do you need?
    Did you try a print_r($listings) to see how it is structured?

  5. #5
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i want for each listing his account id, like i want to view new listings add to website and i want to view for each listing the name and photo for seller or dealer,
    if i use print_r($listings) i will get array like this
    PHP Code:
      Array (
        [
    0] => Array
            (
                [
    name] => Automobiles
                
    [ID] => 1
                
    [Account_ID] => 0
            
    )
        [
    1] => Array
            (
                [
    name] => Automobiles
                
    [ID] => 2
                
    [Account_ID] => 1
            
    )
        
        [
    2] => Array
            (
                [
    name] => cars
                
    [ID] => 3
                
    [Account_ID] => 5
            
    )
            .
            .
            .
            .
        ) 

  6. #6
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,401
    Mentioned
    147 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by jone kent View Post
    i want for each listing his account id
    Then you'll have to loop through the array with foreach

  7. #7
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,401
    Mentioned
    147 Post(s)
    Tagged
    4 Thread(s)
    PHP Code:
    foreach ($listings as $key => $value) {
        
    $dealer_id $value['Account_ID'];
        
    $dealer $rlAccount -> getDealerInfo($dealer_id);
        
    $rlSmarty -> assign_by_ref('dealer'$dealer);


  8. #8
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorrry not working for me i dont know why (

  9. #9
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,401
    Mentioned
    147 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by jone kent View Post
    not working for me
    What does "not working" mean? An error?

  10. #10
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    look here (i pm you) for each listing have profile pic i want to get it, and look accounts id in array in top
    PHP Code:
            foreach($listings as $key => $value) {
                
    $seller_id =  $value['Account_ID'];
                
                
    $seller_info $rlAccount -> getProfileInfo$seller_id );
                
    $rlSmarty -> assign'seller_info'$seller_info );

                echo 
    $value['Account_ID'];
                    } 

  11. #11
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,401
    Mentioned
    147 Post(s)
    Tagged
    4 Thread(s)
    It looks like the Account_ID is varying, so that should be correct, right?
    Then maybe getProfileInfo() is returning the wrong info? Try doing a var_dump of $seller_info.

  12. #12
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    its get correct info, you can check it

  13. #13
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,401
    Mentioned
    147 Post(s)
    Tagged
    4 Thread(s)
    Ok, so the loop gets all the correct info, but it doesn't display correctly? Then the error might lie in $rlSmarty -> assign( 'seller_info', $seller_info ); , but I don't know smarty, so I can't help you with that.

  14. #14
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    its ok, at lest i know now where is the poblem thank you guido2004

  15. #15
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello guido2004
    when i changed your code to
    PHP Code:
                foreach($listings as $key => $value) {
                
    $dealer_id =  $value['Account_ID'];
                
                
    $dealer $rlAccount -> getProfileInfo$dealer_id );
                
    $rlSmarty -> assign'dealer'$dealer );

                
    var_dump($dealer_id);
                    } 
    i get another array can you check it please??


Bookmarks

Posting Permissions

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