Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2005
    Posts
    12
    Plugin Contributions
    0

    Default External SQL Query

    Hi,

    We have been using zen cart for a few years now and always been happy with it. As we use it to book events alot of our pages that advertise each event are outside of the zen cart enviroment.

    What im hoping to be able to do is show or echo the places / prodcuts remaining for each ID within each external page. Im happy that I would have to add this eash time I made a event page but would be so much better than me having to knock the places off each time manually.

    I know it's a case of connecting to the database but not 100% sure of the sql or php query. Can anyone help me on this please ?

    Thanks
    Nick

  2. #2
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: External SQL Query

    It really depend. If the other sites are on a different servers, for security purpose most hosts often lock down external access to mysql server. You can add your external sites to the "safe list" but this is not recommended.

    Let us know if these sites are on the same server or not. We have different solutions for different cases.
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  3. #3
    Join Date
    Oct 2005
    Posts
    12
    Plugin Contributions
    0

    Default Re: External SQL Query

    Hi yellow1912 and thank you for the quick response.

    Yes it is all on the same server. Had dealings myself in the past trying to get info from another domain and our hosts do have that locked down but I can see why.

    Thanks again
    Nick

  4. #4
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: External SQL Query

    Great. There is one thing I forgot to ask, you say you want to "show or echo the places / prodcuts remaining for each ID", what does it mean? Something like: product 127 has 2 items left?
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  5. #5
    Join Date
    Oct 2005
    Posts
    12
    Plugin Contributions
    0

    Default Re: External SQL Query

    Hi again yellow1912,

    I hope you don't mind but im going to send you a PM as I don't really want to publicise the domain and directories, I do hope anyone else reading this is not offended.

    Basically all we need is for it to echo the number available for that ID and nothing else.

    Thanks again for your time in this matter
    Nick
    Last edited by bittyboy; 23 Sep 2007 at 02:55 PM. Reason: Realised you cannot PM

  6. #6
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: External SQL Query

    Sure, PM me.

    Regards
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  7. #7
    Join Date
    Oct 2005
    Posts
    12
    Plugin Contributions
    0

    Default Re: External SQL Query

    PM Sent ;)

  8. #8
    Join Date
    Oct 2005
    Posts
    12
    Plugin Contributions
    0

    Idea or Suggestion Re: External SQL Query

    I sent a private message to yellow1912 and he was very very helpful.

    He basically ended up creating the script for me and spent the a good part of the day doing so.

    For anyone that might be interested in a similar script to show the amount of products available outside of Zen Cart here it is.

    <?php
    define('IS_ADMIN_FLAG', true);
    define('ZC_ABSOLUTE_PATH','/your/path/here/to/includes');
    require(ZC_ABSOLUTE_PATH.'includes/configure.php');
    require(ZC_ABSOLUTE_PATH.'includes/database_tables.php'); // set your path here
    require(ZC_ABSOLUTE_PATH.'includes/classes/class.base.php'); // set your path here
    require(ZC_ABSOLUTE_PATH.'includes/classes/db/mysql/query_factory.php'); // set your path here

    $db = new queryFactory();
    $db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE, USE_PCONNECT, false);

    function get_quantity($id){
    global $db;
    $row= $db->Execute("SELECT products_quantity FROM ".TABLE_PRODUCTS." WHERE products_id =".$id);

    return $row->fields['products_quantity'];
    }

    echo get_quantity (12); //product id in here
    ?>

    Thank you for your time once again yellow1912

 

 

Similar Threads

  1. Replies: 9
    Last Post: 12 Jul 2023, 12:26 AM
  2. v154 Help with a SQL Query for Query Builder
    By lindasdd in forum Managing Customers and Orders
    Replies: 2
    Last Post: 24 Mar 2016, 01:18 PM
  3. v151 SQL query setup. How do I TEST a query 'off-line'?
    By lewisasding in forum General Questions
    Replies: 3
    Last Post: 8 Mar 2013, 12:24 AM
  4. Replies: 2
    Last Post: 15 Aug 2011, 04:58 AM
  5. SQL Query
    By rgoetz in forum Customization from the Admin
    Replies: 5
    Last Post: 9 Aug 2006, 09:15 AM

Posting Permissions

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