xavier.rayne Posted October 4, 2007 Share Posted October 4, 2007 Hi,there. I'm quite new to php and now working with the popup box that appears for the first person who login to the system daily, weekly and bi-weekly. So,how to check whether the person is the first person who login to the system and popup a message box for him? I really have no idea on it :'( Please help me. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/71753-weekly-bi-weekly-in-php/ Share on other sites More sharing options...
SammyGunnz Posted October 4, 2007 Share Posted October 4, 2007 What box, exactly? You might want to clarify what it is you're talking about, buddy. Quote Link to comment https://forums.phpfreaks.com/topic/71753-weekly-bi-weekly-in-php/#findComment-361451 Share on other sites More sharing options...
darkfreaks Posted October 4, 2007 Share Posted October 4, 2007 post the login code please ??? Quote Link to comment https://forums.phpfreaks.com/topic/71753-weekly-bi-weekly-in-php/#findComment-361454 Share on other sites More sharing options...
xavier.rayne Posted October 4, 2007 Author Share Posted October 4, 2007 Sorry, guy Here is the code for the page that i want the popup box to appear: <?php session_start(); if(isset($_SESSION["session_post"])) { if ($_SESSION['session_post'] == "Admin") { include("../../config_sales.php"); $date = date("g:i A Y-m-d"); $h = substr($date,0,2); if($h>=10){ $h = substr($date,0,2); $min = substr($date,3,2); $d1 = substr($date,9); //get current date $m1 = substr($date,14,2); $am = substr($date,6,2); }else{ $h = substr($date,0,1); $min = substr($date,2,2); $d1 = substr($date,; $m1 = substr($date,13,2); $am = substr($date,5,2); } if($am=="PM" && $h<12){ $h = $h+12; }else{ $h=$h; } $t1 = substr($date,0,; //assign 1st popup timestamp $popup = mktime($h,$min,0,date("m"),date("d"),date("Y")); $day = diswk($d1); $tomorrow = day_tomorrow($d1); $dT =substr($tomorrow,8,2); $popT = mktime($h,$min,0,date("m"),$dT,date("Y")); $a = date("g:i A Y-m-d",$popT); $week = week($d1); $dW =substr($week,8,2); $popW = mktime($h,$min,0,date("m"),$dW,date("Y")); $b = date("g:i A Y-m-d",$popW); $biweek = bi_week($d1); $dB =substr($week,8,2); $popB = mktime($h,$min,0,date("m"),$dB,date("Y")); $c = date("g:i A Y-m-d",$popB); $popup2 = ""; //check whether there is someone login before daily $queryD = "SELECT * FROM clean WHERE popup2<='$popup' AND type='1'"; echo $queryD; $resultD = mysql_query($queryD); $numD =mysql_num_rows($resultD); $rowD = mysql_fetch_array($resultD); $msg = $rowD['msg']; if($numD==1){ //popup message?> <script>alert('Have you clean the toilet?');</script> <script>alert('Is all of your jobs are done?');</script> <? $queryUD = "UPDATE clean SET popup1='$popup' WHERE popup2<='$popup'"; echo $queryUD; mysql_query($queryUD); $query = "SELECT * FROM clean WHERE popup2<='$popup' AND type='1'"; echo $query; $result = mysql_query($query); $row = mysql_fetch_array($result); $p1 = $row['popup1']; $day1 = date("g:i A Y-m-d",$p1); $h2 = substr($day1,0,2); if($h>=10){ $h2 = substr($day1,0,2); $min2 = substr($day1,3,2); $day2 = substr($day1,9); $m2 = substr($day1,14,2); $am = substr($day1,6,2); }else{ $h2 = substr($day1,0,1); $min2 = substr($date,2,2); $day2 = substr($day1,; $am = substr($day1,5,2); } if($am=="PM" && $h<12){ $h = $h+12; }else{ $h=$h; } $tomorrow2 = day_tomorrow($day2); $y2 = substr($tomorrow2,0,4); $m2 = substr($tomorrow2,5,2); $d2 = substr($tomorrow2,8,2); $to2 = mktime($h2,$min2,0,$m2,$d2,$y2); $queryUD2 = "UPDATE clean SET popup2='$to2' WHERE popup1='$popup'"; echo $queryUD2; $resultUD2 = mysql_query($queryUD2); }else if ($numD==0){ //popup message?> <script>alert('Have you clean the toilet?');</script> <script>alert('Is all of your jobs are done?');</script> <? $queryI = "UPDATE clean SET popup1='$popup', popup2='$popT' WHERE type='1'"; echo $queryI; mysql_query($queryI); } //check whether there is someone login before weekly $queryW = "SELECT * FROM clean WHERE popup2<='$popup' AND type='2'"; echo $queryW; $resultW = mysql_query($queryW); $numW = mysql_num_rows($resultW); //echo "NUM".$numW; $rowW = mysql_fetch_array($resultW); $msg = $rowW['msg']; if($numW==1){ //echo $msg; //popup message?> <script>alert('Have you clean the indoor air-conditioner?');</script> <? $queryUW = "UPDATE clean SET popup1='$popup' WHERE popup2='$popup'"; echo $queryUW; mysql_query($queryUW); $query2 = "SELECT * FROM clean WHERE popup2<='$popup' AND type='2'"; echo $query2; $result2 = mysql_query($query2); $row2 = mysql_fetch_array($result2); $p1 = $row2['popup1']; $day1 = date("g:i A Y-m-d",$p1); //echo "DAY!".$day1; $h2 = substr($day1,0,2); if($h>=10){ $day2 = substr($day1,9); $m2 = substr($day1,14,2); }else{ $day2 = substr($day1,; $m2 = substr($day1,13,2); } //echo "DD".$day2; $week2 = week($day2); //echo "WEEK2 ".$week2; $d2 = substr($week2,8,2); //echo $d2.",".$m2.",".$y2; $m2 = substr($week2,5,2); $y2 = substr($week2,0,4); $popup2 = mktime(2,0,0,$m2,$d2,$y2); $queryUW2 = "UPDATE clean SET popup2='$popup2' WHERE popup1='$popup'"; echo $queryUW2; $resultUW2 = mysql_query($queryUW2); }else if ($numW==0){ $queryI2 = "UPDATE clean SET popup1='$popup',popup2='$popW' WHERE type='2'"; echo $queryI2; mysql_query($queryI2); } //check whether there is someone login before biweekly $queryBW = "SELECT * FROM clean WHERE popup2<='$popup' AND type='3'"; echo $queryBW; $resultBW = mysql_query($queryBW); $numBW = mysql_num_rows($resultBW); $rowBW = mysql_fetch_array($resultBW); $msg = $rowBW['msg']; if($numBW==1){ //popup message?> <script>alert('Have you clean the outdoor air-conditioner?\n');</script> <? $queryUBW = "UPDATE clean SET popup1='$popup' WHERE popup2<='$popup'"; echo $queryUBW; mysql_query($queryUBW); $query3 = "SELECT * FROM clean WHERE popup2<='$popup' AND type='3'"; echo $query3; $result3 = mysql_query($query3); $row3 = mysql_fetch_array($result3); $p1 = $row3['popup1']; $day1 = date("g:i A Y-m-d",$p1); //echo "DAY!".$day1; $h2 = substr($day1,0,2); if($h>=10){ $day2 = substr($day1,9); $m2 = substr($day1,14,2); }else{ $day2 = substr($day1,; $m2 = substr($day1,13,2); } //echo "DD".$day2; $biweek2 = bi_week($day2); echo $biweek2; $d2 = substr($biweek2,8,2); $m2 = substr($biweek2,5,2); $y2 = substr($biweek2,0,4); $popup2 = mktime(15,0,0,$m2,$d2,$y2); $queryUW2 = "UPDATE clean SET popup2='$popup2' WHERE popup1='$popup'"; echo $queryUW2; $resultUW2 = mysql_query($queryUW2); }else if ($numBW==0){ //popup message?> <!--<script>alert('Have you clean the toilet?');</script> <script>alert('Is all of your jobs are done?');</script>--> <? $queryI3 = "UPDATE clean SET popup1='$popup', popup2='$popB' WHERE type='3'"; echo $queryI3; mysql_query($queryI3); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>Sky Online Sales Reporting System - Menu Admin</title> </head> <body> <font color="#FF0000"> <center><h3>Sky Online Sales Reporting System</h3></center></font> <tr align="center"><td colspan="10" class="content"><p class="welcometxt"><?php echo "Welcome, " .$_SESSION['session_user']; ?></p> <p class="welcometxt"> </p></td></tr> <TR> <TD COLSPAN=10 valign="top" class="content" height=""><table cellpadding="3" cellspacing="5" border="0" align="center" width="449" class="content"> <tr> <td><a href="registration.php"><img src="images/emp.jpg" width="40" height="40" border="0" /></a></td> <td><a href="registration.php">Employee Registration </a> </td> <td><a href="employeeList.php"><img src="images/edit.jpg" width="40" height="40" border="0" /></a></td> <td><a href="employeeList.php">Employee Profile </a></td> </tr> <tr> <td><a href="registrationF.php"><img src="images/mMember.gif" width="40" height="40" border="0" /></a></td> <td><a href="registrationF.php">Franchiser Registration </a> </td> <td><a href="franchiserList.php"><img src="images/edit.jpg" width="40" height="40" border="0" /></a></td> <td><a href="franchiserList.php">Franchiser Profile </a></td> </tr> <tr> <td><a href="menuReport.php"><img src="images/sales.jpg" width="40" height="40" border="0" /></a></td> <td><a href="menuReport.php">Sales Report </a> </td> <td><a href="salesView.php"><img src="images/sales1.jpg" width="40" height="40" border="0" /></a></td> <td><a href="salesView.php">Edit Sales</a> </td> </tr> <tr> <td><a href="branchView.php"><img src="images/branch.jpg" width="40" height="40" border="0" /></a></td> <td><a href="branchView.php">Branch </a> </td> <td><a href="changepswdA.php"><img src="images/mPsw.gif" width="40" height="40" border="0" /></a></td> <td><a href="changepswdA.php">Change Password </a></td> </tr> <tr> <td><a href="resetpswd.php"><img src="images/reset.jpg" width="40" height="40" border="0" /></a></td> <td><a href="resetpswd.php">Reset Password </a> </td> <td><a href="../signout.php"><img src="images/mOut.gif" width="40" height="40" border="0" /></a></td> <td><a href="../signout.php">Sign Out</a> </td> </tr> </table> </body> </html> <?php } else {header("Location:../signin.php?msg=You do not have the authority to access the page");} } else {header("Location:../signin.php");} function diswk($d){ $y1= substr($d,0,4); $m1= substr($d,5,2); $d1= substr($d,8,2); $wk = date("l", mktime(0,0,0, $m1, $d1, $y1)); return $wk; } function bi_week($d){ $y1= substr($d,0,4); $m1= substr($d,5,2); $d1= substr($d,8,2); $biweek = date("Y-m-d", mktime(0,0,0, $m1, $d1+14, $y1)); return $biweek; } function day_tomorrow($d){ $y1= substr($d,0,4); $m1= substr($d,5,2); $d1= substr($d,8,2); $tomorrow = date("Y-m-d", mktime(0,0,0, $m1, $d1+1, $y1)); return $tomorrow; } function week($d){ $y1= substr($d,0,4); $m1= substr($d,5,2); $d1= substr($d,8,2); $week = date("Y-m-d", mktime(0,0,0, $m1, $d1+7, $y1)); return $week; } ?> The 'Have you clean the toilet?' and 'Is all of your jobs are done?' popup for the 1st person who login in a day for everyday. The 'Have you clean the indoor air-conditioner?' popup for the 1st person who login in a week for every week. The 'Have you clean the outdoor air-conditioner?' popup for the 1st person who login in a day for twice a week. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/71753-weekly-bi-weekly-in-php/#findComment-361514 Share on other sites More sharing options...
xavier.rayne Posted October 4, 2007 Author Share Posted October 4, 2007 here is the table structure for table clean: CREATE TABLE `clean` ( `type` int(2) NOT NULL default '0', `msg` text, `popup1` int(11) default NULL, `popup2` int(11) default NULL, `empId` int(11) default NULL, PRIMARY KEY (`type`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; the type field holds 3 rows of data: type 1 for daily popup type 2 for weekly popup type 3 for biweekly popup msg holds the popup message popup1 holds the timestamp for 1st time popup popup2 holds the timestamp for 2nd time popup empId holds the member that login to the system Thanks alot. Quote Link to comment https://forums.phpfreaks.com/topic/71753-weekly-bi-weekly-in-php/#findComment-361516 Share on other sites More sharing options...
solarisuser Posted October 4, 2007 Share Posted October 4, 2007 For daily, thats easy. Make a new field called "daily", and have the login code update that field with the CURRENT_TIMESTAMP whenever a successfull login occurs. Then for the actual code to determine if they are the first, you can select daily from table where daily != '', and figure out how to order the timestamp so the earliest one is first, and then use LIMIT 1 to get it. then grab the uid from that result and you know who it was... Hi,there. I'm quite new to php and now working with the popup box that appears for the first person who login to the system daily, weekly and bi-weekly. So,how to check whether the person is the first person who login to the system and popup a message box for him? I really have no idea on it :'( Please help me. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/71753-weekly-bi-weekly-in-php/#findComment-361525 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.