Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About hokletrain

  • Rank

Profile Information

  • Gender
    Not Telling
  1. Thanks for all the help again, Req. The issue is that the ID/SerialNumber is dynamic and changes a lot. I looked at your previous answer got kind of confused so just stuck with your first suggestion. Processed the date through PHP rounded to nearest 15 minutes and stored as proper date. Code works almost perfectly with what i have above. Now that the dates are rounded properly , I get a lot of looped results is that because I'm using date = date and so on? Example query: SELECT d.RH,b.AT,c.WSAV,d.date FROM test d, test b, test c WHERE d.RH IN (SELECT RH FROM test WHERE sn = 5165654) AND
  2. I'm kind of confused in which part of the query i would apply the date_format part to. Would i select it at the start e.g SELECT d.$sensor,b.$sensor1,c.$sensor2,DATE_FORMAT(SEC_TO_TIME(ROUND(TIME_TO_SEC(d.date) / 900) * 900), "%Y-%m-%d %H:%i") as dd.date? Or could i just use it at the end as a group by DATE_FORMAT(SEC_TO_TIME(ROUND(TIME_TO_SEC(d.date) / 900) * 900), "%Y-%m-%d %H:%i") ? And even then how could i apply this to the other date fields like b.date and c.date? Sorry I'm quite new to this particular MySQL , thanks for all the help Req.
  3. I also still want to keep the original date's which is why i haven't rounded in my insert script. I only want to do this rounding part for calculations
  4. I'm using PHP to insert JSON data into the MySQL table, which gives me a date I'm just using the varchar to store it in the PHP formatted datetime. I can still use every MySQL date function with the varchar though aha? I pretty much just want to get records of data that are inside the period of 15 minutes, hence why I'm trying to round it. In my case could i use FLOOR? e.g SEC_TO_TIME(FLOOR((TIME_TO_SEC(CURTIME())+450)/900)*900).
  5. d.date is a varchar , which has been formatted!
  6. Hey guys, the data in my database gets inputted at dates within the hour, I'm trying to round each date to the nearest 15 minute interval. I have tried to use SEC_TO_TIME but wasn't working. I'm trying to calculate data for every 15 minutes. Example dates: 2017-09-05 09:01 , 2017-09-05 09:05 , 2017-09-05 09:17 , 2017-09-05 09:24 First two dates should 'round' to 9:00 and the second set should 'round' to 9:30. Current Query: "SELECT d.$sensor,b.$sensor1,c.$sensor2,d.date FROM test d, test b, test c WHERE d.$sensor IN (SELECT $sensor FROM test WHERE sn = $rtu) AND b.$sensor1
  7. The screenshot is just a snippet from PHPmyAdmin. Could i use the same kind of query loops that i have but nest the query loops like such: while($row = mysqli_fetch_array($query1)) { $x = $row['sensor']; while($row = mysqli_fetch_array($query2)) { $y = $row['sensor1']; while($row = mysqli_fetch_array($query3)) { $z = $row['sensor2']; $step1 = str_replace("x",$x,$formula); $step2 = str_replace("y",$
  8. Thanks for the responses guys. Sorry Barand i can attach some data if it makes it easier. I would probably prefer using SQL to get the data as a whole anyway. I do like the idea of completing the process in MySQL. If i used joins inside of one query and then looped results could i still process this similar to above -e.g $x = $row['sensor]; . Also the sensors and unit_id's can change completely so the above MySQL statements only really works for the three sensors RH, AT and AVGWN? This is the major reason i use the calculation table , because of how much information can vary.
  9. Hey guys, i have been working on a script for a little while now and just can't seem to find a solution.The issue I'm having is that i can't seem to loop through multiple tables using a primary tables information. In the bottom case i have two records with the same title 'fire_index' which has the same formula, the only thing that differs is the sensors and unit_id's have changed. Breakdown of steps: 1.) Automatically loop through calculation table retrieve all records with desired title e.g 2 records , fire_index 2.) Use the information retrieved from the calculation table to buil
  10. The only issue with using an array location is that the the name changes so there can be multiple underlined parts before it reaches the serial number e.g Test_camera_DEMO_782300. I have been working on a different way which essentially works with one file at time operated by a CRON job ? In the front end when a sensor unit is made a folder is also created with the serial number. I'm getting the latest image chucking it into an array, then trying to match the serial number contained in the image file name with the folder name? If matched copy image to folder? My Current Code Which does
  11. I think i am too, i tried this piece I'm getting an error :
  12. Hey guys , I'm quite new to PHP and have been working on a piece of code for a while now and just can't seem to find a solution. I'm trying to make a script which copy's images from a folder to another folder on the web server. The folder names on the web server will be the serial number in the image name. So basically i want to get the serial number from the image name, create folder with 'serial number' as the name if folder exists don't make a new folder. And then copy the image to that folder? I can find loads on filtering arrays but nothing on working with the array elements. Is there a w
  13. Okay i'm gonna give that a crack. Is it bad to execute so many query's separately? Once again thanks for all the help Sep.
  14. Thanks for clearing up so much guys! Sepodati thanks for adding some code as well. As far as inserting each value into the database tables, whats the best way to go about that?
  15. Yes i gathered the $data['data']['RH'] part of the code isn't right , hence why i posted it just to see if i can find the proper way of doing it? And oh okay the fourth element, can you please explain that part? I haven't used JSON with PHP before so i'm quite new to how some of the code works. And yes that's correct sometimes there will be more of those: { "$ts": 170801170000, "RH": 67.15, "AT": 12.87, "MINVi": 3.81, "PTi": 23.4, "LWS": "0*T", "WSAV": 0, "WSMX": 0, "WSMN": 0, "PR_TOT": 156, "RAIN": 0, "FDI": 0.239, "DT": 2.881, "WD": "0*T", "P1": "0*T", "AVGCi": 175 } If the file c
  • 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.