PHP - Mysql Select Datas After Time Interval
guys, please help
i have table with datas like speed of vehicle, position e.t.c from morning 8 a.m. to 8 p.m. I need to get these details, but after every 15 minutes i.e. after selecting datas at 8 a.m. it shd select datas @ 8.15 a.m. then 8.30 a.m. hw can i write a mysql query for this ? or a PHP approach is appreciated Similar TutorialsHI,
I was trying do add a function to my script to stop each 10 seconds, using max_execution_time. Apparently is not working and most probably from the php.ini file, that I can t change because I want for the others script to run normally.
How can I write a function inside a php file to stop everything after 10 seconds. Or how can I make a script to stop after 100 processed items and start again after 30 seconds. I need to stop this file somehow. $processedItems++; Does any one know how to run PHP script automatically at specific time interval in my local machine. I am using Windows 7. What about using the Task scheduler ? Please write to me in details how to give the path of the php page in Task Scheduler. Hello.. I'm a somewhat beginner in php, but i decided to create my own basic forums system with a content managing system. Right now I'm trying to figure out how to make a thread link be at the top of the list for the forum display page, when someone posts a response or creates a new thread. HELP MUCH APPRECIATED I've been researching online resources and seen a lot of code and functions for calculating an interval or difference between two date/time figures. What I'm trying to do is somewhat in reverse... I want to establish an interval to determine a past date/time to be used in a MySQL Query but just can't figure the critical part.
// STEP #1 = DEFINE THE DESIRED DATE/TIME DIFFERENCE INTERVAL DESIRED FOR QUERIES $timeinterval = '60'; // Interval is in MINUTES and can be changed as desired // STEP #2 = GET THE CURRENT LOCAL SERVER DATE/TIME // as YYYY-MM-DD HH:MN:SE $serverdatetime = date('Y-m-d H:i:s'); // My local Server Date & time // STEP #3 = CALCULATE THE ***PAST** (OLDER) DATE/TIME LIMIT BASED ON $timeinterval (Minutes) // as YYY-MM-DD HH:MN:SE $pastdatetime = [stuckinarut here] <- 60 MINUTES prior to current Server Date/Time // STEP #4 = MySQL QUERY (`submitted` column is auto-timestampped on record insertions) $sql="[columnsblahblah] FROM mydb WHERE `submitted` >= $pastdatetime";In a Perfect World, the MySQL Query would yield ONLY records with a `submitted` DATE/TIME equal to 60 Minutes (or less) PRIOR TO from the Current Server Time. Any assistance is appreciated! Thanks. -FreakingOUT This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=310181.0 Hello. I have a mysql database with an 'entrytime' field which contains the unix timestamp the record was added. How do I create a mysql query to select all records for a given month/year? For example, if I wanted to create a query to display all records for October 2010 how do I go about it? I am at a loss and can't find my answer via google. Thanks in advance for any help! i am a newbie.. From my tables, what code should i put to put into my site? in text.. guys please help, i have an array(52,51,52) here i want to insert first & last elements into DB, not second one does not follows the series another array (52,52,53) in this case insert first 2 elements into DB since last element does not follow the series. how is this possible? Dear All, I have login script already. i have two database one is users and another one is reference in both user_name is common. In this if a user login and search the refid means that user datas onle possible to retrieve. for others datas they cant access. i wrote the below code but it display all user datas. kindly help me <?php session_start(); if (!$_SESSION["user_name"]) { // User not logged in, redirect to login page Header("Location: login.php"); / } // Member only content // ... $con = mysql_connect('localhost','root',''); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("login", $con); $user_name = $_POST['user_name']; $query = "select * from reference,users where reference.user_name=users.user_name and reference.refid='$refid'"; $result = mysql_query($query) or trigger_error('MySQL encountered a problem<br />Error: ' . mysql_error() . '<br />Query: ' . $query); while($row = mysql_fetch_array($result)) { echo $row['refid']; echo $row['origin']; echo $row['dest']; echo $row['date']; echo $row['exdate']; echo $row['user_name']; } echo "<p><a href=\"logout.php\">Click here to logout!</a></p>"; ?> <html> <form method="post" action="final.php"> Ref Id:<input type="text" name="refid"> <input type="submit" value="submit" name="submit"> </html> I have database "raj" with table "pagination"
In table pagination have "id", "actualtime" and "created" field
id - auto_increment actualtime- varchar created- datetime
that looks like this CREATE TABLE pagination( id int auto_increment, actualtime varchar(55), created datetime )
I want to display all rows which are created on todays date and will display from today upto yesterday at 06:00 pm. after that the content will be refreshed based on based on a DATETIME field called 'created' that holds the date and time of each record's creation.
this is my query to fetch rows but it display value after 06:00 pm on yesterday but i want to display all data before 06:00 pm from currentdate. After 06:00 pm data will be refreshed and clear. plz help me......
SELECT actualtime FROM pagination WHERE created BETWEEN date_add(date_sub(curdate(), INTERVAL 1 day), INTERVAL 18 hour) AND curdate()";
Hey Guys. I am trying to create a time dropdown and increment eat by an an hour until it is lless than or equal to the end time. I am using the DateTime class to accomplish this.
Now when I am trying to use a for loop to accompish this it does not work. Can anyone please help me out with this issue?
Below is the code that I have
$start_hour = new DateTime("now",new DateTimeZone("America/New_York")); $start_hour->setTime(6,00); $formatted_start_time = $start_hour->format("H:i:s"); $end_hour = mktime(11,45); for($start_hour; $start_hour <= $end_hour; $start_hour->modify("+60 minutes"));{ echo "<select name='cat_display_timeslot'>"; echo "<option>{$formatted_start_time}</option>"; echo "</select>"; }Thanks! Edited by eldan88, 24 August 2014 - 07:21 PM. Hello everybody, I have found a lot of amazing advises and codes to improve on my existing codes. It seems to be an awesome site. I actually came from a background of Application programming, however I have just recently pick up a project in php. The project is about database integration, where I have to integrate 5 supplier's existing data who have different attributes into one. (each suppliers have about 30k data) I really need help and advises on how should I do the script. Here's the details, All the suppliers uses different data file, such as CSV and .xls. I am finding a way to integrate all the 5 files into one database(mysql/phpmyadmin) so it could be listed out in a shopping cart or catalog in future. However, I am unfamiliar with php, so please advice on how can i go about fixing this problem. The first problem is that each individual suppliers uses a different attributes name, for example Supplier 1 uses : SupplierName, SupplierID, SupplierAddress, Status Inside the status, the supplier uses data such as, Good, Excellent, Great while Supplier 2 uses : SName, SID, SAddress, Status and inside this supplier, the status data that are being uses is G, Ex, Gr. How can I set a consistancy on the data and converting all the properties into one so I can import this data into a proper database such as mysql/phpmyadmin. Please help, thanks in advance I'm very beginner with arrays.... i KNOW, databases exist, it's more easy.. I can't use a database.. I have to use, this.. or similar.. that doesn't requiring a database engine... So... that array...
array ( ); I search by the element [#][0].. in the +250 some will contain the same infos and I would like to make them point to the element containing the info instead of repeating it and have to update at 3-4 places when it's time. Like what it's in "10" also good for "ten", "dix" and "diez"... anyway to make that simple? by reference or...??? I'm crying.. last time I used arrays... Turbo Pascal.. at school... or was it Turbo C++ 3.0?? Maybe it was with cobol... well it was the good ol' time of the 90s!
Thanks!
-TRP-
I hav a php page which takes data from the db.But the problem i am facing is for a particular fild in database ,i have long data,which i need to b displayed in a wordwrap way eg my data is " Description need a site for school gave order on 12-10-2010 work started on 12-10-2010 " this shuld be displayed as "Description need a site for school gave order on 12-10-2010 work started on 12-10-2010" Description is the field in the database and rest of them are the datas in it Hi all. In my database, i have a column recurring which is derived from a multiple option form field with values: Weekly, Bi-Monthly, Monthly, Quarterly, Half Yearly and Yearly. I want to have as next due the current date plus the recurring value. eg current date = 2014-11-24 recurring = monthly next due = current date + recurring (in the next due will be 2014-12-24) so i did: $stmt = $pdo->query("SELECT recurring, due_date FROM $table"); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $recur = $row['recurring']; $date_due = $row['due_date']; } $weekly = "Weekly"; $bi_monthly = "Bi-Monthly"; $monthly = "Monthly"; $quarterly = "Quarterly"; $half_yearly = "Half Yearly"; $yearly = "Yearly"; if(strcmp($recur, $weekly) == 0){ $recurs = "7 DAY"; }elseif(strcmp($recur, $bi_monthly) == 0){ $recurs = "14 DAY"; }elseif(strcmp($recur, $monthly) == 0){ $recurs = "1 MONTH"; }elseif(strcmp($recur, $quarterly) == 0){ $recurs = "3 MONTH"; }elseif(strcmp($recur, $half_yearly) == 0){ $recurs = "6 MONTH"; }elseif(strcmp($recur, $yearly) == 0){ $recurs = "1 YEAR"; } $stmt = $pdo->query("SELECT ADDDATE('$date_due', INTERVAL $recurs) as nex_due FROM $table"); $row = $stmt->fetch(PDO::FETCH_ASSOC); $nex_due = $row['nex_due']; $stmt = $pdo->prepare("SELECT * FROM $table ORDER BY trans_id DESC"); $stmt->execute(); $num_rows = $stmt->rowCount(); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['trans_ref']; echo "</td><td>"; echo $row['acct_num']; echo "</td><td>"; echo ucwords($row['payee']); echo "</td><td>"; echo ucwords($row['company']); echo "</td><td>"; echo $row['acct_no']; echo "</td><td>"; echo number_format($row['amt'],2); echo "</td><td>"; echo $row['purpose']; echo "</td><td>"; echo $row['recurring']; echo "</td><td>"; echo $row['due_date']; echo "</td><td>"; echo $nex_due; echo "</td><td>"; echo "<strong>".$row['status']."</strong>"; echo "</td><td>"; echo "<strong>".$row['pay_status']."</strong>"; echo "</td><td>"; } The problem is that it's giving me as next due the value of the first row even when the recurring is different! Hey, I'm not that familiar with PHP so maybe what I'm asking for is not even possible. I plan to establish a webserver that is connected to a RS232 device. I don't have any problems accessing the RS232 interface with a PHP-script, it's all working fine. Now I want the incoming data from the device being display on the servers webpage almost in realtime. When I say almost I mean that the client who is logged on to the website should be able to define the update rate of the incoming data. So here comes the problem, I need something like the java script setinterval() function that is working on the server-side and repeats the data request to the device in an infinite loop with the given time interval. I don't want to refresh the whole page as I will have to update about 20 sets of data within seconds! I found this code: http://phpclasses.chimit.nl/package/5544-PHP-Call-a-function-after-a-period-of-time.html it looks pretty promissing but I just can't make it working... As I said I'm a PHP-noob so I just put the code below on the start of my own code and provided the Timer.class.php file in my project folder. Could anyone explain how I could make the test function repeating endlessly on a 1sec basis using this code so I would get a screen full of "called"? So far I only get two "called" :-) Thanks! declare(ticks=100); function test () { print "<br>called"; } require_once 'Timers.class.php'; setTimeout('test', 110000000); setInterval('test', 10000000); So I have a php script in public_html on my apache server, and it runs a global economy code for my browser game. If I open firefox and go to: http://localhost/Economy.php it runs the code, and it changes all the values in the database properly. How do I get that to run automatically, say every 6 minutes? I have windows so no cron jobs. I went to task scheduler and created a task which I thought would work, and it lists the task as running. But it gives me an error. Event Views: Code: [Select] Log Name: Microsoft-Windows-TaskScheduler/Operational Source: Microsoft-Windows-TaskScheduler Date: 9/28/2011 5:02:37 PM Event ID: 101 Task Category: Task Start Failed Level: Error Keywords: (1) User: SYSTEM Computer: Matt-PC Description: Task Scheduler failed to start "\Economy" task for user "Matt-PC\Matt". Additional Data: Error Value: 2147750687.Event Xml: Code: [Select] <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> <System> <Provider Name="Microsoft-Windows-TaskScheduler" Guid="{DE7B24EA-73C8-4A09-985D-5BDADCFA9017}" /> <EventID>101</EventID> <Version>0</Version> <Level>2</Level> <Task>101</Task> <Opcode>101</Opcode> <Keywords>0x8000000000000001</Keywords> <TimeCreated SystemTime="2011-09-28T22:02:37.967669800Z" /> <EventRecordID>18</EventRecordID> <Correlation /> <Execution ProcessID="1012" ThreadID="1484" /> <Channel>Microsoft-Windows-TaskScheduler/Operational</Channel> <Computer>Matt-PC</Computer> <Security UserID="S-1-5-18" /> </System> <EventData Name="TaskStartFailedEvent"> <Data Name="TaskName">\Economy</Data> <Data Name="UserContext">Matt-PC\Matt</Data> <Data Name="ResultCode">2147750687</Data> </EventData> </Event> EDITed for code tags I am coding a browser game in php/mysql. the economy code needs to run at a regular interval. How can I get my code to run say, every 6/12/24 minutes? I heard of something called a cron job, but im not sure if it is going to be what I need. Hi guys. I want to make two records. 1)Current time and date. 2)Time and date after 20 seconds. Now i have this piece of code: Code: [Select] <?php $hr = 0; $min = 0; $sec = 11; echo $date = date("Y-m-d H:i:s");echo "\n"; echo $modified = time() + (0 * 0 * 0 * 20); ?> I think there is something wrong with this line: Code: [Select] <?php echo $modified = time() + (0 * 0 * 0 * 20);1 ?>I get something like this: 1324668576. You can check this http://kingstonuni.atspace.co.uk/RPG/muziejus.php link to get a better view. Any help would be appreciated. Thank you. This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=331688.0 |