1.0.2 Adding {COUNTRY} to browse auctions

Discussion in 'General Support' started by pani100, Jun 3, 2011.

  1. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    2,327
    Likes Received:
    449
    Hi,
    I am trying to ad the location of the item on the browse pages of the auctions.It will be country and possibly city or prov
    I know something similar is called on the item page under {COUNTRY} {ZIP} from item.php.
    What query should I add to the php files and where to get this working also on the browse.tpl?
    I'm guessing it should be in the browse.php and calling from the users table but I do not know how to syntax it and in which database query to actually add it in.
    I have no idea on database calls. And searching has got me more confused if anything.
    Any help or guidance welcome.


    as I understand it so far:
    browseitems.inc.php
    in the: $template->assign_block_vars('featured_items', array(
    added: 'COUNTRY' => $row['country'],
    and
    in the: $template->assign_block_vars('items', array(
    added: 'COUNTRY' => $row['country'],

    and on the browse.tpl have added the {featured_items.COUNTRY} and {items.COUNTRY} to show on the page but I know I have to call it from the database somehow unless it just needs a different way of assigning it.
    The same will have to be done for the city and/or prov too once I get the first part working.
     
    Last edited: Jun 3, 2011
  2. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    2,327
    Likes Received:
    449
    Lets try again,
    Trying to add in the auctions list the location of each item.
    I need to pull the zip and country or just the country for each auction for the browseitems.inc.php.
    Do I do a separate query linking the auction (user) with users(country) or do I have to add it into the original query (which I think is in the browse.php).
     
  3. laura458

    laura458 New Member

    Joined:
    Feb 4, 2011
    Messages:
    368
    Likes Received:
    30
    I've been working on this one. I've put the shipping costs in the browse areas, but was having a problem with the zip and city doing it the same way.
     
  4. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    2,327
    Likes Received:
    449
    Laura458,
    YES....I have manged to do it but only for the featured items in the listings (browse).
    Tonight I will be on the search for where the normal listing query comes from.....

    We are getting there...
     
  5. landf01

    landf01 New Member

    Joined:
    Feb 27, 2011
    Messages:
    2
    Likes Received:
    0
    Hi pani and laura,
    I have also been attempting the same function. My coding skills are not the best, but I have found in the item.php this call to u.country. In the database this is where I think the page is getting the call to show the auction country, for the item.tpl {COUNTRY} call.

    Here in item.php:
    // get auction all needed data
    Line 40: $query = "SELECT a.*, ac.counter, u.nick, u.reg_date, u.country, u.zip FROM " . $DBPrefix . "auctions a
    LEFT JOIN " . $DBPrefix . "users u ON (u.id = a.user)
    LEFT JOIN " . $DBPrefix . "auccounter ac ON (ac.auction_id = a.id)
    WHERE a.id = " . $id . " LIMIT 1";


    and


    Line 447: $template->assign_vars(array(
    'COUNTRY' => $auction_data['country'],));

    Like you I've been working on this one for a while and i'm stumped.
     
    Last edited: Jun 12, 2011
  6. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    2,327
    Likes Received:
    449
    I GIVE UP!..not.
    Just been looking at the code for the categories in browse.php for a whole night, boy I can not make anything out. Gone back to the drawing board.
    Am approaching it a different way now. I have manually added 4 columns in the auction table (country, prov, city and zip) transferred over the data from users table. That seems to work a treat. Here is the code:

    create extra colums in auctions table (first 4 lines)> USED ONLY ONCE to create the columns
    copy over from users table (last 4 lines)

    ALTER TABLE webid_auctions ADD city varchar(25) default '';
    ALTER TABLE webid_auctions ADD prov varchar(20) default '';
    ALTER TABLE webid_auctions ADD country varchar(25) default '';
    ALTER TABLE webid_auctions ADD zip varchar(10) default '';

    UPDATE webid_auctions SET city = (SELECT city FROM webid_users WHERE webid_users.id = webid_auctions.user);
    UPDATE webid_auctions SET prov = (SELECT prov FROM webid_users WHERE webid_users.id = webid_auctions.user);
    UPDATE webid_auctions SET country = (SELECT country FROM webid_users WHERE webid_users.id = webid_auctions.user);
    UPDATE webid_auctions SET zip = (SELECT zip FROM webid_users WHERE webid_users.id = webid_auctions.user);

    If you go to browseitems.inc.php and in your:
    $template->assign_block_vars('featured_items', array(
    and
    $template->assign_block_vars('items', array(
    add in both:
    'CITY' => $row['city'],
    'COUNTRY' => $row['country'],
    'ZIP' => $row['zip'],
    'PROV' => $row['prov'],

    next go to browse.tpl
    and add {featured_items.COUNTRY} , {featured_items.PROV} , {items.CITY}, {featured_items.ZIP} in the BEGIN featured section
    and {items.COUNTRY}, {items.PROV}, {items.CITY}, {items.ZIP} in the BEGIN items section it shows all up.

    At the moment you will have to run the last 4 database queries every time you add an item.
    My coding skills are 0 so if anyone knows how to shorten the queries be my guest. I have tried by could not get it right.
    Now all that is left is to put these 4 UPDATE queries in the sell.php to be called when a new item is created so it does it automatically and probably in the edit data.php so if you change your address details again it updates.
    Come on nearly there.
    Nearly forgot. need to change in the functions_sell.inc.php line 204 at the end of the query.
    ends like this:
    $_SESSION['SELL_is_featured'] . "', " . $fee . ")";
    and needs to be like this if you want to keep the adding of the items working.
    $_SESSION['SELL_is_featured'] . "', " . $fee . ", '', '', '', '')";

    The additional '' could be coming from the register.php one day...
     
    Last edited: Jun 12, 2011
  7. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    2,327
    Likes Received:
    449
    continued...
    In sell.php find around line 99 find:
    // insert auction
    $query = addauction();
    if ($_SESSION['SELL_action'] == 'edit')
    $query = updateauction(1);
    if ($_SESSION['SELL_action'] == 'relist')
    {
    remove_bids($_SESSION['SELL_auction_id']); // incase they've not already been removed
    $query = updateauction(2);
    }
    $res = mysql_query($query);
    $system->check_mysql($res, $query, __LINE__, __FILE__);

    and add after:

    $query = "UPDATE webid_auctions SET city = (SELECT city FROM webid_users WHERE webid_users.id = webid_auctions.user)";
    $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);

    $query = "UPDATE webid_auctions SET prov = (SELECT prov FROM webid_users WHERE webid_users.id = webid_auctions.user)";
    $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);

    $query = "UPDATE webid_auctions SET country = (SELECT country FROM webid_users WHERE webid_users.id = webid_auctions.user)";
    $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);

    $query = "UPDATE webid_auctions SET zip = (SELECT zip FROM webid_users WHERE webid_users.id = webid_auctions.user)";
    $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);

    That seems to update the table once the new auction has been entered so no need to run the 4 queries every time a new auction is entered.

    If someone with any experience on coding could have a look and see if I have done something that I should of not please say so.
     
  8. landf01

    landf01 New Member

    Joined:
    Feb 27, 2011
    Messages:
    2
    Likes Received:
    0
    Pani100,

    It works!!! Just tried it out on my site and I am getting the countries to work. Thank you so much. Will keep looking into this in hopes that I can be of some help.
     
  9. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    2,327
    Likes Received:
    449
    Hi landf01,
    Glad its working. :)
    I have been testing it through the weekend and have had no problem come up. As I say maybe someone with more knowledge could run it through, they might be able to shorten the Update queries to just one.
    Anyway enjoy.
     
  10. dacp927

    dacp927 New Member

    Joined:
    Jan 11, 2016
    Messages:
    4
    Likes Received:
    0
    Hello pani100, Im sorry, but I didnt understand the 1º step, could you help me, please
     
  11. hhavatar

    hhavatar Donor Donor

    Joined:
    Jul 28, 2014
    Messages:
    747
    Likes Received:
    74
    If you're referring to browseitems.inc.php thats now browse.php in the main directory. Thread refers to an older version.
     

Share This Page