PHP - Php Schedule Comparision Solution
Similar TutorialsHi, This may be the wrong way to do things but I am fairly new to this. I have a mysql database which I store some jobs I run. I usually use schedule tasks for this but was wondering if I could do this more efficiently in PHP. I have a table with days of the week comma seperated and then a column with a time and then a column with the name of the job. I basically need something to kick off a job at a given time on a certain day. If someone can point me in the right direction it would be appreciated and I can usually crack on from there I currently have the below code that reads a database to find what time a staff member is scheduled for work and what day. The below code works fine however on the same day it print lets say they work more then one hour it would show Sunday 2a - 3a, Sunday 3a - 4a, Sunday 4a - 5a ..... and so on I would just like it to simply put Sunday 2a - 5a skipping the extra output. $dayname = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); $shifts = array(); $num=0; $days=0; for ($d = 0; $d <= 6; $d++) { $slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$dayname[$d]'")); for ($i = 1; $i <= 24; $i++) { $ap1 = "a"; $ap2 = "a"; if ($slot["$i"] == $eusername) { $one = $i-1; if($one >= 12) { $one = $i-13; if($one == 0) { $one = 12; } $ap1 = "p"; } $two = $i; if($two >= 12) { $two = $i-12; if($two == 0) { $two = 12; } $ap2 = "p"; } $shifts[$num] .= $dayname[$d].' '.$one.''.$ap1.' - '.$two.''.$ap2.' EST<br>'; $num++;}} } if($shifts[0] != NULL){ echo"<table><tr><td><strong>Air Shifts:</strong></td><td>"; for ($i = 0; $i <= $num; $i++) { if($i == 0) {echo $shifts[$i].'</td></tr>';} else {echo '<tr><td></td><td>'.$shifts[$i].'</td></tr>';} }} print"</table>"; I'm new here so I say hallo to everyone I have to implement bus time table in this way: Every bus drives every second day from the day chosen. Let's say: If xx bus goes every second day from 23rd February to 30th June to Spain (23rd, 25th, 27th...), How can I check if let's say on 14th May there is bus to Spain? I started with odd and even numbers: if it starts from the even day than there is array of months with number of days, but what if Feb has 29days (every 4th year) instead of 28... I'm totally confused here. In database I have rows: start date, end date and bus name. Is there any other way of implementing this? Hi everyone I need some help on how to go about designing a script for a high school. It is for teachers so that they can book periods for the computer lab, studio etc. I want it so when they go to the page it has this week with all the slots taken. What I'm having trouble with is I want them to also be able to go to any date they wish and bring up that weeks schedule because they need to be able to book in advance. Would anyone be able to explain a technique on how I can go about this Thanks in advance I am trying to write a simple method of displaying our meetings schedule for North Idaho Area Narcotics Anonymous it pulls from a MySQL database and I want it to look like this: COEUR D'ALENE Sunday: Group 1 Name Time Group 2 Name Time Group 3 Name Time Monday: Group 1 Name Time Group 2 Name Time POST FALLS Sunday: Group 1 Name Time Ok so my problem is I dont know how to make php create the heading only if there are meetings in that heading so if there are no meetings in POST FALLS then it wont make a list for post falls or if there are no meetings in POST FALLS on Sunday then it wont show the SUNDAY heading. This way it will be maintenance free page just add/delete meetings in the database then go from there. Each meeting name will be a link to an ID corresponding to the unique ID in the database so you click it then read all the info on that meeting. It will be a way for NA members to view the schedule from their mobile phones easily. I have written loops but nothing that would leave out a heading based on lack of a given entry. Any help would be most appreciated. Thank you!!! Chad hello guys. i need to run a script automatically at scheduled date and time. i am sending bulk emails . i need to setup an email campaign, in such a way that i can schedule like daily, monthly or quarterly.. can u guys give few tips to get it done.. This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=342882.0 I need help to get flight schedule from http://www.sriwijayaair.co.id/id but always error using curl to access ssl. here are my code: <?php $headers = array( "User-Agent=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 GTB7.1 (.NET CLR 3.5.30729)", "Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language=en-us,en;q=0.5", "Accept-Encoding=gzip,deflate", "Accept-Charset=ISO-8859-1,utf-8;q=0.7,*;q=0.7", "Keep-Alive=1150", "Connection=keep-alive", "Referer=http://www.sriwijayaair.co.id/id", "Cookie=language=in; location=id; dest=home; __utma=260465999.1394002812.1293106375.1293106375.1293106375.1; __utmb=260465999.1.10.1293106375; __utmc=260465999; __utmz=260465999.1293106375.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)", "Content-Type=application/x-www-form-urlencoded", "Content-Length=121", "POSTDATA=isReturn=false&from=CGK&to=MES&departDate1=30-&departDate2=11-2010&adult=1&child=0&infant=0&returndaterange=0&Submit=Cari" ); // do access to sriwijaya air $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, "https://booking.sriwijayaair.co.id/b2c/AvailabilityServlet"); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_HEADER, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_VERBOSE, 1); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($curl, CURLOPT_COOKIEJAR, "cookie.txt"); //curl_setopt($curl, CURLOPT_POSTFIELDS, "isReturn=false&from=CGK&to=MES&departDate1=22&departDate2=01-2011&adult=1&child=0&infant=0&returndaterange=0&Submit=Cari"); $curlData = curl_exec($curl); print_r($curlData); curl_close($curl); ?> any help will be appreciate, thanks Hi there, I am working on a php project on my WAMP server where I have access to XML datafeed from xe.com once a day to get the Exchange rates. This xml datafeed is saved on my localhost as an archived copy. Now I would like to automatically access the fresh xml datafeed file from xe.com once a day and replace (or update) the xml file on my localhost to have the updated information (rates). How can I schedule this task automatically and make php access the updated xml file once a day. All comments and feedbacks are always welcomed Thank you! 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()";
I've got a class schedule that spans two years and I would like to have the years as headers. startDate is unix date field. Here is existing code: $sql = "SELECT * FROM classOfferings, classes, instructors WHERE classes.classId = classOfferings.classId AND classOfferings.instructorId = instructors.instructorId AND classOfferings.startDate >= CURDATE() ORDER BY classOfferings.startDate"; if(! $retval ) { die('Could not get schedule: ' . mysql_error()); } while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) { echo "{$row['dates']}"; if ($row['hours'] != 0){ echo "</td> "; } else { echo "CANCELLED</td>"; } echo "<td class='cell2'>". "<a href='classDetail.php?seq={$row['seq']}'>{$row['title']}</a>". "{$row['days']}". "{$row['times']}". "<a href='instructorDetail.php?instructorId={$row['instructorId']}'>{$row['fName']} "." ". "{$row['lName']}</a></td>} echo "</td></tr></table></div>"; } Hi Folks, I'm creating an equipment reservation system for a client. Every reservation has an equipmentID, ReservationDate, StartTime, EndTime. So, basically my script searches existing records for a given date and EquipmentID. I'm having trouble with how best to approach validation on new reservations to ensure there are no conflicts. Lets say two existing reservations for a given date/equipment are found. One reservation has a startTime of 8AM and endTime of 9AM. The second has a startTime of 12PM and endTime of 3PM. Is there a simple way to check if the user's submitted values for StartTime and EndTime conflict with existing reservations? Any input would be greatly appreciated! Thanks! -John Hi all, I am wondering what the best way to do this is... Take GoDaddy for example, if your domain is about to expire you will get an automatic email. I am wanting to do something similar, If someone orders a Soap Dispenser, I want to send an email (if they accept to receiving emails on the order) each month asking/reminding them to top up on soap. I have been reading but cant find anything adequate, I have seen something about Cron Jobs, but never heard of this before, please could you point me in the right direction. Thanks in advance. Peter Hi, I am having trouble with some GIF, PNG images the error I am receiving these errors imagecreatefromgif() [function.imagecreatefromgif]: '/tmp/phpNAhLPI' is not a valid GIF and a similar one for PNG Is there a solution to this? and How can I hide these errors? So they never display to the user and Instead I echo a user friendly error. Please note again this is happening with some GIF and PNGs not all of them. Appreciate any help and thanks in advance! SQL error2.Cannot add or update a child row: a foreign key constraint fails (`facility`.`fapplication`, CONSTRAINT `fapplication_ibfk_1` FOREIGN KEY (`fstaffid`) REFERENCES `fstaff` (`fstaffid`)) is there any solution for this problem cause my deadline is next week aaaaa... My friend has this problem, it needs a solution. I have no PHP experience, I don't know how to work with MD5 hash. A programming unit was compulsory on her course, but she completely fails on it. So let's be unethical and help her survive it. thanks in advance ===================== You are the website administrator for a website that requires a low level password for entry. The previous owner of the website forget to code in a password recovery feature and as such you now have to recover the passwords for a number of users of the website. You do have acess to the website databse BUT you are NOT allowed to manually change the passswords for users in the database as those passwords are heavily used in defining what permissions a user of the website has. e.g Moderators for the website forum all have a password begining with the lower case letter "m" in lower case. ALL letters are lowercase. Passwords were allocated to all users and the method of choice was to create a password which was built on two parts - a lowercase letter "m" and a number between 1 and 10000. An md5 hash was then created to form a 32 digit string. e.g the user with password "m1234" is represented in the database as the md5 hash: 77c12394ef7d4f23a8fa07d87309afd9 You have five users who need their orignal password. You know that the passwords all start with the letter "m". You decide that the simplest thing to do is to write some PHP code that uses a while loop to increment through the numbers 0 to 10000, concatenate that number with the "m" and then compare the md5 hash to that you recovered from the database. If the two hashes are the same then you have "cracked" the password. This technique is known as a "brute force" method of cracking passwords. You have a number of hashes to "crack" and you must enter the unique password into the answer box for each. As a starting point, the following PHP snippet will produce all of the lowercase letters: ___________________________________ Code: [Select] for ($i=97; $i<=122; $i++){ $x = chr($i); echo $x; } ?> I'm really fond of your coding and need some help too I'm also trying to make a tree and save it in an xml file such that parent_id of one node is inserted in as pages key to the father node.By running this query $sql = "Select * from category order by parent_id ASC"; I'm getting the following result. Array ( => Array ( [category_id] => 2 [parent_id] => 0 [category_name] => Clothes ) [1] => Array ( [category_id] => 5 [parent_id] => 1 [category_name] => T-shirts ) [2] => Array ( [category_id] => 6 [parent_id] => 1 [category_name] => Cotton-Shirts ) [3] => Array ( [category_id] => 1 [parent_id] => 2 [category_name] => Upper ) [4] => Array ( [category_id] => 4 [parent_id] => 2 [category_name] => Lower ) [5] => Array ( [category_id] => 3 [parent_id] => 4 [category_name] => Pants ) ) My code is as follows but not executing correctly function searchTree($arr,$node,$i){ if(!in_array($node['parent_id'],$arr[$i])) { $stmt = '<pages_'.$i.'>'; $stmt .=$node; $stmt .='</pages_'.$i.'>'; return $stmt;} else{ //print_r($returnTree); print_r ($arr[$i]);//['category_id']; $returnTree = ($arr[$i]['category_id']==$node['parent_id'])? searchTree($arr,$node,$i++): searchTree($arr,'',$i++); } } $i=0; foreach($links as $link){ $myArr = searchTree($links,$link,$i);} The result should be as follows: <page_1> <label>Clothes</label> <uri>#</uri> <pages> <page_1_1> <label>Upper</label> <uri>#</uri> <pages> <label>T-Shirt</label> <uri>#</uri> <page_1_1> <page_1_1_1> <label>Short Sleaves</label> <uri>#</uri> </page_1_1_1> <page_1_1_2><label>Long Sleaves</label><uri>#</uri> </page_1_1_2></page_1_1></page_1> <page_1_2> <label>Lower</label> <uri>#</uri> <pages>....</page_1_2> Hopefully you can unsderstand this problem. Please help me. Ok I have a form that will include some text boxes and two sliders where numbers can be selected. When a user clicks submit I want it to take them to a solutions page based on what numbers they have selected. I'm finding it hard to explain what I'm trying to do so heres an example of what I would like. http://www.cleardebt.co.uk/#help It will be a form like that which links to a solution. If someone could please tell me what I need to do or have a tutorial of something similar it would be a great help for me to start. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=349561.0 hey guys i wrote an quick and dirty anagram solver for a challenge on hts which works great but i am more interested on feedback of how I could have written it better / more efficiently. anyone have there own version of writing this? thanks Code: [Select] $scramwords = array("htssboe","rtefcelh","vteevl","edsiyn","awloddno","dtey1d","kuedci","seellhy","sernin","acianro"); $unscramwords = array(); $filename = '../wordlist.txt'; // loop through scrambled words foreach($scramwords as $scramword) { // open the file if($fh = fopen($filename,'r')) do { // read line $line = fgets($fh); // see if line and scrambled word are same length if((strlen(trim($line))) == (strlen(trim($scramword)))) { //if they are the same length split the line into and array and the scrambled word into an array $l = array(); for($i=0;$i<strlen(trim($line));$i++){ $l[$i] = substr(trim($line),$i,1); } $s = array(); for($i=0;$i<strlen(trim($scramword));$i++){ $s[$i] = substr(trim($scramword),$i,1); } $errors = 0; // see if the arrays are different $chk = array_diff($l,$s); if(!empty($chk)){ $errors = 1; } // see if arrays are different in reverse order $chk2 = array_diff($s,$l); if(!empty($chk2)){ $errors = 1; } // found scrambled word if(!$errors) { array_push($unscramwords,$line); } } }while(!feof($fh)); fclose($fh); } // print out comma seperated un scrambled words echo implode(",",$unscramwords); |