Jump to content

nydeveloper

Members
  • Posts

    12
  • Joined

  • Last visited

nydeveloper's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. This post is starting to fall back a few pages, and I'm wondering if perhaps I haven't posted it under the best topic.
  2. $query = $this->db->query('SELECT * FROM coinQuote WHERE date < DATE_SUB(CURDATE(), INTERVAL 60 MINUTE)'); In the query above, my goal is to select the rows from a table named coinQuote where the value in the date column (type = timestamp) is older than 60 minutes from the current time. This works perfectly until every night around 2:00 AM my time (EST), which I believe is midnight on my server's time, almost every row in the table is selected. This only happens once a day (the code with the above query runs every few minutes via a cron job) - the same time every day. It's obvious to me that the date change is what's causing the issue. Unfortunately I'm having a really tough time fixing it. Am I taking the wrong approach here, or is this approach acceptable with a little tweaking?
  3. I'm trying to create an if statement that checks a string and determines if it contains x number of characters. For example, if $test has 3 characters then <action>. The second part of my question involves the <action>. What I'm looking to do is append a specific character set to the beginning of said string. For example: $test = 'abc' If $test consists of 3 characters then { $test = '1234' appended to the beginning of the original value of $test } else { do nothing } In this example, the final value of $test would be '1234abc' Thanks in advance for any guidance here.
  4. I'm running PHP with CodeIgniter and have completed some functions, run every x minutes by cron jobs, that update specific data values in my local DB. The next step of my project is to display these values on my home page, which is simple enough. However, what I'd like to do is display this data in a way that it will auto update every x seconds if that data value has changed in my DB. My assumption is the best way to do this will be via jQuery/AJAX, but this is where I'm stuck. I've done some research and believe that I have jQuery properly enabled in my CI installation, but I'm not clear on the next step. The majority of examples that I've found on the Web deal with handling form data, radio button selections, menu selections, etc without the need for a refresh, button press, page submission, etc. However, I can't seem to find any help on what I'm trying to achieve - which seems fairly straight forward. I realize that this is a PHP forum, and not specific to the CI framework, but the community here seems extremely knowledgable and willing to help out so I figured I'd give it a try first. Any guidance here is appreciated. Thanks in advance for your time.
  5. I was able to upgrade my PHP version, and the code worked perfectly! Thanks so much! The next step now is to pull that JSON response from a URL as opposed to having it hardcoded. This is my approach, and it works just fine, but I'm wondering if this is the most efficient method. What are your thoughts on this? $ch = curl_init(); // set url curl_setopt($ch, CURLOPT_URL, "<URL GOES HERE>"); //return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $output contains the output string $data = curl_exec($ch); // close curl resource to free up system resources curl_close($ch); $data=json_decode(trim($data),true);
  6. I didn't run the earlier code, since I knew that I couldn't use 'test'. I'm running PHP version 5.2.17 on a dedicated server. Is there a minimum version that I need to upgrade to?
  7. By the way, solution or not, I totally intend to donate. The detailed and timely responses on this forum are second to none. I'm extremely impressed.
  8. Thanks again. Using the latest code snippet above, I receive the following error "Parse error: syntax error, unexpected T_FUNCTION" associated with this line.
  9. Very sorry about that. You're correct. I thought I had included that piece of information in my original post. Below is the JSON response once again, this time with the dynamic element names (those that can change) highlighted in red. It can be assumed that those names not highlighted in red will always remain as is. {"success":1,"return":{"test":{"marketid":"32","label":"test\/TEST1","primaryname":"TestItem","primarycode":"ABC","secondaryname": "Tester","secondarycode":"TES","sellorders":[{"price":"0.00002894","quantity":"13.31323200","total":"0.00038528"},{"price":"0.00002895","quantity":"92.80350000","total":"0.00268666"},{"price":"0.00002897","quantity":"392.60350000","total":"0.01137372"},{"price":"0.00002900","quantity":"392.50350000","total":"0.01138260"},{"price":"0.00002902","quantity":"785.40700000","total":"0.02279251"}],"buyorders":[{"price":"0.00002734","quantity":"93.16130210","total":"0.00254703"},{"price":"0.00002733","quantity":"2.00000000","total":"0.00005466"},{"price":"0.00002731","quantity":"2.31057540","total":"0.00006310"},{"price":"0.00002599","quantity":"3.73174150","total":"0.00009699"}]}}}
  10. Understood, but the issue here is that using 'test' could be a problem, as that attribute will change from time to time. The names 'return', 'sellorders', and 'buyorders' on the other hand, will always remain the same - so they can be utilized to sort and parse. 'test' can't be hardcoded, so I was trying to figure out the exact need for it in the structure of your code... and if there is a way around utilizing it.
  11. Thanks for the quick and detailed reply, and for catching that errant comma! I have a question about your sample code. What is the purpose of utilizing ['test']?
  12. I'm having a really tough time using curl to parse the following data, which is returned as JSON via a URL. What I need to do is take the lowest 'price' found within 'sellorders' and assign it to a local variable, and then take the highest price found within 'buyorders' and assign that to a second local variable. Any help here is greatly appreciated. {"success":1,"return":{"test":{"marketid":"32","label":"test\/TEST1","primaryname":"TestItem","primarycode":"ABC","secondaryname": "Tester","secondarycode":"TES","sellorders":[{"price":"0.00002894","quantity":"13.31323200","total":"0.00038528"},{"price":"0.00002895","quantity":"92.80350000","total":"0.00268666"},{"price":"0.00002897","quantity":"392.60350000","total":"0.01137372"},{"price":"0.00002900","quantity":"392.50350000","total":"0.01138260"},{"price":"0.00002902","quantity":"785.40700000","total":"0.02279251"},],"buyorders":[{"price":"0.00002734","quantity":"93.16130210","total":"0.00254703"},{"price":"0.00002733","quantity":"2.00000000","total":"0.00005466"},{"price":"0.00002731","quantity":"2.31057540","total":"0.00006310"},{"price":"0.00002599","quantity":"3.73174150","total":"0.00009699"}]}}}
×
×
  • 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.