PHP - Calculate 5 Working Days Prior To A Give Date
Hi all,
I am trying to figure out how to calculate 5 working days prior to a given date. I have done some googling but can only see examples of how to add 5 working days onto a date, such as this: Code: [Select] $holidayList = array(); $j = $i = 1; while($i <= 5) { $day = strftime("%A",strtotime("+$j day")); $tmp = strftime("%d-%m-%Y",strtotime("+$j day")); if($day != "Sunday" and $day != "Saturday" and !in_array($tmp, $holidayList)) { $i = $i + 1; $j = $j + 1; } else $j = $j + 1; } $j = $j -1; echo strftime("%A, %d-%m-%Y",strtotime("+$j day")); Does anyone know how to calculate 5 working days prior to a date? Many thanks, Greens85 Similar TutorialsI have date stored in database in any of the given forms 2020-06-01, 2020-05-01 or 2019-04-01 I want to compare the old date with current date 2020-06-14 And the result should be in days. Any help please? PS: I want to do it on php side. but if its possible to do on database side (I am using myslq) please share both ways🙂 Edited June 14, 2020 by 684425Hi there, i am using a form with 2 inputs which are equipped with a datepicker: Date 1 & Date 2, is it possible to calculate how many days are there from Date 1 to Date 2 (including the selected ones) ? On my form the dates are in this format: September 08, 2011 (i guess i can change that to numeric only, if that helps) Tamper data shows them getting posted like this: September+14%2C+2011 Any help / hints will be appreciated ! is there an easy way to add weekdays to a stored date ... so far i have echo date ( 'Y-m-j' , strtotime ( '5 weekdays' ) ); this adds 5 weekdays to the current date , can i have it add 5 weekdays to say $TableDate 1; Thanks in advance... Hello all, The exact thing that i need is to calculate how much days there is in between two dates. The only problem is that every thing that i found dont care about leap year Anyone have a function to do that? Hi, I need to calculate absent percentage but not sure how. working days from Sunday to Thursday every week so 5 working days a week. i will calculate the absent days from joining date until current date. Example if joining date is 24-3-2020 and today's date is 7-4-2020 i should get the number of absent days to 11 days since both Friday and Saturday are excluded. How to do that? here is what I have: $workingdays = $curdate - $joindate; $workingdays = $workingdays - $absent = ($counter / $workingdays) * 100; the second line i missing the number of days for (Fridays and Saturdays) that should be excluded from calculations. The third line i did calculate the actual working days ($counter) for the employee so then i can get percentage of absent days. How to exclude the weekend days from calculations? Edited April 1, 2020 by ramiwahdanmistake in dates Hi, I have this code :- $datestarted = $row['datestarted']; $datestart=date("l d/m/Y @ H:i:s",strtotime($datestarted)); Which is been echo'd like this :- echo ' <tr align="center"'.$rowbackground.'> <td>'.$datestart.'</td> <td align="center"> '; So for example I get this output :-Sunday 18/04/2021 @ 10:45:26 The data in the DB for the above is stored like this :-2021-04-18 10:45:26  What I'd like to do is also echo how many days ago this date was, all of the examples I've tried don't seem to work though? I've tried several scripts to get the number of days between two dates, but none of them will work. Obviously I'm doing something wrong. One thing I know that is causing a problem is that I'm using variables instead of an actual typed in date. Which in my opinion is how most people would do it - variables not actual dates. I've tried these: $todaydate = date('Y/m/d'); $now = date('Y-m-d'); $dd2 = strtotime($now); $thisyear = 2019; $payment_day = 29; $pay_month = 6; if($pay_month == 1){$newpaymentmonth = 2;} if($pay_month == 2){$newpaymentmonth = 3;} if($pay_month == 3){$newpaymentmonth = 4;} if($pay_month == 4){$newpaymentmonth = 5;} if($pay_month == 5){$newpaymentmonth = 6;} if($pay_month == 6){$newpaymentmonth = 7;} if($pay_month == 7){$newpaymentmonth = 8;} if($pay_month == 8){$newpaymentmonth = 9;} if($pay_month == 9){$newpaymentmonth = 10;} if($pay_month == 10){$newpaymentmonth = 11;} if($pay_month == 11){$newpaymentmonth = 12;} if($pay_month == 12){$newpaymentmonth = 1;} $threezero = array(4, 6, 9, 11); // months with 30 days // Deal with months that have only 28 days or 30 days, setting the payment day to accommodate months with fewer days. if ($payment_day > 28 && $pay_month == 2) { $payment_day = 28; } elseif ($payment_day == 31 && in_array($pay_month, $threezero)) { $payment_day = 30; } else { $payment_day = $payment_day; } if ($newpaymentmonth == 1){$newpaymentyear = $thisyear + 1;}else{$newpaymentyear = $thisyear;} $newpaymentdate = date($newpaymentyear.'-'.$newpaymentmonth.'-'.$payment_day); echo date("Y-m-d", $newpaymentdate) . "<br><br>"; $ddate = new DateTime($thisyear.'-'.$newpaymentmonth.'-'.$payment_day); $ddate->add(new DateInterval('P5D')); echo $ddate->format('Y-m-d') . " - New month payment date with 5 day grace period added.<br><br>";
Now, how to calculate the difference in days between today's date and $ddate? I tried the below, but none worked. function DateDiff($strDate1,$strDate2){ return (strtotime($strDate2) - strtotime($strDate1))/ ( 60 * 60 * 24 ); // 1 day = 60*60*24 } echo "Date Diff = ".DateDiff($now,$ddate)."<br>"; $timeDiff = abs($now - $ddate); $numberofdays = $timeDiff/86400; echo "<p>$numberofdays - days between today's date and payment w/grace date.</p>"; $date1 = $now; $date2 = $ddate; $diff = date_diff($date1,$date2); echo 'Days Count - '.$diff->format("%a"); $date1=$now; $date2=$ddate; function dateDiff($date1, $date2) { $date1_ts = strtotime($date1); $date2_ts = strtotime($date2); $diff = $date1_ts - $date2_ts; return round($diff / 86400); } $dateDiff= dateDiff($date1, $date2); printf("Difference between in two dates : " .$dateDiff. " Days "); print "</br>"; This one returns 18112 Days. Should be days 7 days from 2019-08-05. None of these work, so I'm doing something wrong. Any ideas? Thanks Edited August 9, 2019 by cyberRobotfixed typo Hi, I have a job listing website which displays the closing date of applications using: $expired_date (This displays a date such as 31st December 2019) I am trying to show a countdown/number of days left until the closing date. I have put this together, but I can't get it to show the number of days.                <?php                $expired_date = get_post_meta( $post->ID, '_job_expires', true );                $hide_expiration = get_post_meta( $post->ID, '_hide_expiration', true );                if(empty($hide_expiration )) {                   if(!empty($expired_date)) { ?>                         <span><?php echo date_i18n( get_option( 'date_format' ), strtotime( get_post_meta( $post->ID, '_job_expires', true ) ) ) ?></span>                               <?php                               $datetime1 = new DateTime($expired_date);                               $datetime2 = date('d');                               $interval = $datetime1->diff($datetime2);                               echo $interval->d;                ?>                   <?php }                }                ?> Can anyone help me with what I have wrong? Many thanks I want to see if a date is more than 10 days overdue. if ($row['duedate'] < "todays date plus 10 days"){ How do I do that? I put in quote sup there in "english" what I want... Hi, Hope this is the right place for this... I have php routines that print itineraries. For some reason the timestamp (1351378800) returns the same date Sunday 28th October (2012) as the time stamp (1351465200). $count = 0; while ($count <= ($nights+1)) { echo date ('l', $startdate1)." (".$startdate1.")"; echo "<br>"; echo date ('jS F', $startdate1); $startdate1 += 86400; // more code } Any ideas? Many thanks, Peter I have a SQL row that has a date field: ex: 2010-11-01. When a car is sold there either is a 30 day warranty, a 60 day warranty, or 0 day warranty. What I'm trying to do is display when the vehicles warranty expires, based on the date it was sold, or when did it expire based on the same sold date pulled from the database. Example using last months date: 2010-10-01 60 day: "Expires 11-30-10" 30 day: "Expired 11-01-10" I can not seem to use the date function properly... Any help would be greatly appreciated. Hi fellas, this is really kicking my arse and i know its so simple! I retrieve a date from the database, done! I am manipulating it to display as i want, done! How the hell do i add 365 days to this date? $date= ($row['date']); $subscription = strtotime($date); echo "<p>Subscription renewal date: ". date('l jS F Y', $subscription) . "</p>"; Hi guys, I've hit a brick wall here and am in need of your help. I'm pretty new to PHP and have limited knowledge to say the least. I'll explain what it is I'm trying to do. Set start date as 01/01/2004 (dmY) $oFour Set how many days has it been since then? $today Set how many days it was from $ofour 30 days ago. $today -30 = $thirtyDaysAgo But the problem is I don't know how to make date('z'); work from 2004 and not 01/01/2010. So $today will be how many days it has been since the start of 2004 and $thirtyDaysAgo will be $today -30. I can set up $thirtyDaysAgo no problem but it's just finding out how to get the $today number... Hope anyone can offer a little light to my situation :/ Mav I was wondering if there was a way to have the MAX function NOT return a Date that is more than 2 days into the future (from the current day)? If there is a Date that is more than 2 days into the future I would like to return the one closest to the current day. Here is the code I have: Code: [Select] <?php mysql_connect("local", "xxx", "xxx") or die(mysql_error()); mysql_select_db("pricelink") or die(mysql_error()); // Get a specific result from the "ft9_fuel_tax_price_lines" table $query ="SELECT ItemNumber,TableCode,Cost, MAX(`Date`) as `max_date`, MAX(`Time`) as 'max_time' FROM `ft9_fuel_tax_price_lines` GROUP BY `ItemNumber`,`TableCode`"; $result = mysql_query($query) or die(mysql_error()); echo "<table border='1'>"; echo "<tr> <th>ItemNumber</th> <th>TableCode</th> <th>Date</th> <th>Time</th> <th>Cost</th> </tr>"; // keeps getting the next row until there are no more to get while($row=mysql_fetch_array($result)) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['ItemNumber']; echo "</td><td>"; echo $row['TableCode']; echo "</td><td>"; echo $row['max_date']; echo "</td><td>"; echo $row['max_time']; echo "</td><td>"; echo $row['Cost']; echo "</td></tr>"; } echo "</table>"; ?> Any help would be appreciated. Thanks! Hi, I am trying to get the number of days between the current date and a date in the future specified by column 'end_date'. The code I have seems to be working but it displays the number of days as a negative number, how do I change this to be a positive number? I have tried simply changing $days = $now - $end_date; to $days = $end_date - $now; but that doesn't work as I thought it would! Thanks in advance.. Code: [Select] $now = time(); $end_date = strtotime($row['end_date']); $days = $now - $end_date; echo floor($days/(60*60*24)); i have date of birth stored as DATE type in mysql. i tried this so it would show the age but it comes up blank. Code: [Select] $getprof = mysql_query("SELECT * FROM Profile WHERE username='$search'")or die(mysql_error()); while($rowprof = mysql_fetch_assoc($getprof)) { $username1 = $rowprof['username']; $location = $rowprof['location']; $gender = $rowprof['gender']; $dateofbirth = $rowprof['dateofbirth']; $information = $rowprof['information']; } function GetAge($dateofbirth) { // Explode the date into meaningful variables list($BirthYear,$BirthMonth,$BirthDay) = explode("-", $dateofbirth); // Find the differences $YearDiff = date("Y") - $BirthYear; $MonthDiff = date("m") - $BirthMonth; $DayDiff = date("d") - $BirthDay; // If the birthday has not occured this year if ($DayDiff < 0 || $MonthDiff < 0) $YearDiff--; return $YearDiff; } echo $YearDiff; Hellow, i need help please, writing code and it doesn't work. please help...
Here it is
WHERE start_date BETWEEN 'start_date".strtotime('-3 day')."' AND 'start_date'";without this code everithing works fine Thank you I am really lost here with this date issue of mine. The below code is the last part of a query: Code: [Select] $defendercheck_3 = $row_checkifattacked3['atdate']; $defendercheck1_3 = strtotime("$defendercheck_3"); $defendercheck2_3 = date("D", $defendercheck1_3); The query does not return any results as expected, but when echoing the various steps I get following: echo "$defendercheck3"; = nothing (as expected) echo "$defendercheck1_3"; = nothing (as expected) echo "$defendercheck2_3"; = result! (NOT expected) why does it return anything on "date("D", $defendercheck1_3)" when "$defendercheck1_3" is blank? OK, since today is the 31st, I guess I figured out that strtotime("-1 Month') really only goes back 30 days, so where I think it should be September, its registering October 1st. Is there a fix for this? Code: [Select] $month = date('F Y', strtotime("-1 month")); $month1 = date('F Y', strtotime("-2 month")); $month2 = date('F Y', strtotime("-3 month")); $month3 = date('F Y', strtotime("-4 month")); $month4 = date('F Y', strtotime("-5 month")); $month5 = date('F Y', strtotime("-6 month")); I have 2 dropdowns, both default to 'select'. The query seemed to work ok before I added validation that both dropdowns need to have a value other than 'select' before the query will be run (i.e., "please select a value for both dropdowns"). For one of the dropdowns, the value just prior to that evaluation has a value/year selected, but within that IF evaluation it echos as 'select'. --right before IF--year:2010 post year:2010 year end:2011 owner:C WAGNER ------while in IF--year:select post year:2010 year end:2011 owner:C WAGNER the code is up at brewhas.org/team_history.php any ideas as to why that value seems to change within the IF? Code: [Select] <?php $url_owner = $_GET['owner']; $url_year = $_GET['year']; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Brewhas Keeper League Fantasy Baseball - Team Transaction History</title> <link rel="stylesheet" type="text/css" href="style/bklstyle.css" /> <link rel="stylesheet" type="text/css" href="style/mm_travel2.css" /> <link rel="shortcut icon" href="http://www.brewhas.org/images/favicon.ico"> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr bgcolor="#003300"> <td rowspan="2" nowrap="nowrap" bgcolor="#003300"> </td> <td width="59" rowspan="2" nowrap="nowrap" bgcolor="#003300"><img src="http://www.brewhas.org/images/BKL.jpg" alt="BKLLogo" width="59" height="66"/></td> <td width="608" height="49" align="center" valign="bottom" nowrap="nowrap" bgcolor="#003300" id="logo"><span class="style1">BREWHAS KEEPER LEAGUE </span></td> <td width="415" align="center" valign="bottom" nowrap="nowrap" bgcolor="#003300" id="logo"> </td> <td width="5" rowspan="2" bgcolor="#003300"> </td> </tr> <tr bgcolor="#003300"> <td height="24" align="center" valign="top" bgcolor="#003300" id="tagline"><span class="style2">fantasy baseball</span></td> <td height="24" align="center" valign="top" bgcolor="#003300" id="tagline"> </td> </tr> <tr> <td colspan="6" bgcolor="#003300"><img src="images/mm_spacer.gif" alt="" width="1" height="1" border="0" /></td> </tr> <tr bgcolor="#CCC999"> <td height="15" colspan="5" bgcolor="#CCC999"> <div class="container"> <div style="clear: both; display: block; padding-bottom: 2px;"></div> <ul id="topnav"> <li><a href="http://www.brewhas.org/index.html">Home</a></li> <li><a href="#">Team Pages</a> <span> <a href="http://www.brewhas.org/team_pages/boothby.html">Boothby</a> | <a href="http://www.brewhas.org/team_pages/bradt.html">Bradt</a> | <a href="http://www.brewhas.org/team_pages/jcurry.html">J Curry</a> | <a href="http://www.brewhas.org/team_pages/pcurry.html">P Curry</a> | <a href="http://www.brewhas.org/team_pages/hurlebaus.html">Hurlebaus</a> | <a href="http://www.brewhas.org/team_pages/jankowski.html">Jankowski</a> | <a href="http://www.brewhas.org/team_pages/oneil.html">O'Neil</a> | <a href="http://www.brewhas.org/team_pages/shimizu.html">Shimizu</a> | <a href="http://www.brewhas.org/team_pages/cwagner.html">C Wagner</a> | <a href="http://www.brewhas.org/team_pages/jwagner.html">J Wagner</a> </span> </li> <li><a href="http://www.brewhas.org/rules.html">League Rules</a></li> <li><a href="http://www.brewhas.org/payout_picks.html">Payouts & Draft Order</a></li> <li><a href="http://www.brewhas.org/standings/2010_standings.html">Standings</a> <span> <a href="http://www.brewhas.org/standings/2010_standings.html">2010</a> | <a href="http://www.brewhas.org/standings/2009_standings.html">2009</a> | <a href="http://www.brewhas.org/standings/2008_standings.html">2008</a> | <a href="http://www.brewhas.org/standings/2007_standings.html">2007</a> | <a href="http://www.brewhas.org/standings/2006_standings.html">2006</a> | <a href="http://www.brewhas.org/standings/2005_standings.html">2005</a> | <a href="http://www.brewhas.org/standings/2004_standings.html">2004</a> | <a href="http://www.brewhas.org/standings/2003_standings.html">2003</a> | <a href="http://www.brewhas.org/standings/2002_standings.html">2002</a> | <a href="http://www.brewhas.org/standings/2001_standings.html">2001</a> </span> </li> <li><a href="http://www.brewhas.org/drafts/2011_draft.html">Drafts</a> <span> <a href="http://www.brewhas.org/drafts/2011_draft.html">2011</a> | <a href="http://www.brewhas.org/drafts/2010_draft.html">2010</a> | <a href="http://www.brewhas.org/drafts/2009_draft.html">2009</a> | <a href="http://www.brewhas.org/drafts/2008_draft.html">2008</a> | <a href="http://www.brewhas.org/drafts/2007_draft.html">2007</a> | <a href="http://www.brewhas.org/drafts/2006_draft.html">2006</a> | <a href="http://www.brewhas.org/drafts/2005_draft.html">2005</a> | <a href="http://www.brewhas.org/drafts/2004_draft.html">2004</a> | <a href="http://www.brewhas.org/drafts/2003_draft.html">2003</a> | <a href="http://www.brewhas.org/drafts/2002_draft.html">2002</a> | <a href="http://www.brewhas.org/drafts/2001_draft.html">2001</a> </span> </li> <li><a href="http://www.brewhas.org/excelfiles/alltimeaverages.xls">Records</a></li> <li><a href="http://www.brewhas.org/excelfiles/transactions.xls">Transactions</a></li> </ul> </div> </td> </tr> <tr> <td width="164" bgcolor="#FFFFFF"> </td> <td width="59" bgcolor="#FFFFFF"> </td> <td colspan="4" valign="top" bgcolor="#FFFFFF"> <table border="0" cellspacing="0" cellpadding="2" width="835"> <div align="center"> <tr> <td width="831" height="31" class="pageName"> <div align="left"></div> </td> </tr> </div> </table> </td> </tr> </table> <div id="header"></div> <div id="leftcol_long"></div> <div id="content_long"> <h2>Transaction Search - Team History</h2> <table border="0" cellspacing="0" cellpadding="1" width="95%" align=center> <tr> <td bgcolor="#ffffff" height="35" valign="top" rowspan="2"> <form name="form1" method="post" action="http://brewhas.org/team_history.php"> <table border="0" align=left> <tr> <td>Year: <select name='year'> <option value='select'>SELECT</option> <option value='2011' <?php if($_POST['year'] == '2011') echo "selected"?>>2011</option> <option value='2010' <?php if($_POST['year'] == '2010') echo "selected"?>>2010</option> <option value='2009' <?php if($_POST['year'] == '2009') echo "selected"?>>2009</option> <option value='2008' <?php if($_POST['year'] == '2008') echo "selected"?>>2008</option> <option value='2007' <?php if($_POST['year'] == '2007') echo "selected"?>>2007</option> <option value='2006' <?php if($_POST['year'] == '2006') echo "selected"?>>2006</option> <option value='2005' <?php if($_POST['year'] == '2005') echo "selected"?>>2005</option> <option value='2004' <?php if($_POST['year'] == '2004') echo "selected"?>>2004</option> <option value='2003' <?php if($_POST['year'] == '2003') echo "selected"?>>2003</option> <option value='2002' <?php if($_POST['year'] == '2002') echo "selected"?>>2002</option> <option value='2001' <?php if($_POST['year'] == '2001') echo "selected"?>>2001</option> </select> Owner: <select name='owner'> <option value='select'>SELECT</option> <option value='J BOOTHBY'<?php if($_POST['owner'] == 'J BOOTHBY') echo "selected"?>>J BOOTHBY</option> <option value='K BRADT' <?php if($_POST['owner'] == 'K BRADT') echo "selected"?>>K BRADT</option> <option value='J CURRY' <?php if($_POST['owner'] == 'J CURRY') echo "selected"?>>J CURRY</option> <option value='P CURRY' <?php if($_POST['owner'] == 'P CURRY') echo "selected"?>>P CURRY</option> <option value='R HURLEBAUS' <?php if($_POST['owner'] == 'R HURLEBAUS') echo "selected"?>>R HURLEBAUS</option> <option value='M JANKOWSKI' <?php if($_POST['owner'] == 'M JANKOWSKI') echo "selected"?>>M JANKOWSKI</option> <option value='T ONEIL' <?php if($_POST['owner'] == 'T ONEIL') echo "selected"?>>T ONEIL</option> <option value='C WAGNER' <?php if($_POST['owner'] == 'C WAGNER') echo "selected"?>>C WAGNER</option> <option value='J WAGNER' <?php if($_POST['owner'] == 'J WAGNER') echo "selected"?>>J WAGNER</option> <option value='J BADER' <?php if($_POST['owner'] == 'J BADER') echo "selected"?>>J BADER</option> <option value='M SUH' <?php if($_POST['owner'] == 'M SUH') echo "selected"?>>M SUH</option> </select> </td> <td nowrap class="row1" width="40"><input type="submit" value="Submit" name="submit"></td> <td nowrap class="row1" width="60"></td> <td><p><img src="images/baseball.jpg" alt="baseball" width="8""height=8"" /><span class="style7"> Note: For the 2001 season, only the draft transactions are available.</span></p></td> </tr> </table> </form> </td> </tr> </table> <?php include 'config.php'; include 'opendb.php'; //Include the PS_Pagination class include('ps_pagination.php'); if((isset($url_year))&&(isset($url_owner))) { //If a year and owner appear in the URL, meaning we're past page 1 --> get the year and owner from the URL parms $year_search = $url_year; $owner_search = $url_owner; } else //If a year and owner have not been entered and do not appear in the URL (first time thru) --> get them from the form { $year_search = $_POST['year']; $owner_search = $_POST['owner']; } switch ($year_search) { case "2011": $year_end="2012"; break; case "2010": $year_end="2011"; break; case "2009": $year_end="2010"; break; case "2008": $year_end="2009"; break; case "2007": $year_end="2008"; break; case "2006": $year_end="2007"; break; case "2005": $year_end="2006"; break; case "2004": $year_end="2005"; break; case "2003": $year_end="2004"; break; case "2002": $year_end="2003"; break; case "2001": $year_end="2002"; break; } echo "--right before IF--"; echo "year:".$year_search." "; echo "post year:".$_POST['year']." "; echo "year end:".$year_end." "; echo "owner:".$owner_search." "; //This checks to see if both the year and the owner have been selected. if(($year_search="select")||($owner_search="select")) { echo "<BR>"."------while in IF--"; echo "year:".$year_search." "; echo "post year:".$_POST['year']." "; echo "year end:".$year_end." "; echo "owner:".$owner_search; echo "<p class='style7'>Please select both a year and a team owner.</p>"; exit; } else //sets the query to get the number of rows { $sql = "SELECT * FROM `BKL_TRANSACTIONS` WHERE (((TO_OWNER='$owner_search')OR(FROM_OWNER='$owner_search')) and (TRANS_DT >='$year_search') AND (TRANS_DT <='$year_end'))"; } $count = mysql_query($sql) or die ("Could not execute the query"); //executes the query to count the number of matching rows //Count the number of results $numrows=mysql_num_rows($count); echo "<p class='style7'>Your search: "".$year_search." ".$owner_search."" returned <b>".$numrows."</b> results.</p>"; //Count the number of results /* * Create a PS_Pagination object * * $conn = MySQL connection object (defined in opendb.php) * $sql = SQl Query to paginate * 50 = Number of rows per page * 5 = Number of links * "year=valu1&owner=value2" = Append name parameters ($year_search and $owner_search) to paginations links */ $pager = new PS_Pagination($conn, $sql, 50, 5, "year=$year_search&owner=$owner_search"); /* * The paginate() function returns a mysql result set * or false if no rows are returned by the query */ $rs = $pager->paginate(); //executes the query if(!$rs) die(mysql_error()); if ($numrows == 0) //if no matches, don't display the table exit; else //build the table and insert rows { echo "<table border=1 cellspacing=0 cellpadding=1 width='77%' align=left bordercolor=#666666>"; echo "<tr bgcolor=#cccc99 class='style5'><th width='10%' class='style5'>Date</th>"; echo "<th width='10%' class='style5'>Action</th>"; echo "<th width='12%' class='style5'>From</th>"; echo "<th width='12%' class='style5'>To</th>"; echo "<th width='5%' class='style5'>Pos</th>"; echo "<th width='18%' class='style5'>Name</th>"; echo "<th width='5%' class='style5'>Round</th></tr>"; while ($row = mysql_fetch_array($rs)) { echo "<tr><td width='10%' class='style6'>".$row['TRANS_DT']."</td>"; echo "<td width='10%' class='style6'>".$row['TRANS_ACTION']."</td>"; echo "<td width='12%' class='style6'>".$row['FROM_OWNER']."</td>"; echo "<td width='12%' class='style6'>".$row['TO_OWNER']."</td>"; echo "<td width='5%' class='style6'>".$row['POSITION']."</td>"; echo "<td width='18%' class='style6'>".$row['PLAYER_FNAME']." ".$row['PLAYER_LNAME']."</td>"; echo "<td width='5%' class='style6'>".$row['DRAFT_RND']."</td></tr>"; } //Display the navigation if ($numrows > 50) { echo "<p class='style7'>".$pager->renderFullNav()."</p>"; } echo "</table>"; } ?> </div> <div id="rightcol_long"></div> <div id="footer"><p align="center" class="style8">Brewhas Keeper League - <img src="images/icon_mlb.gif" alt="mlb" width=36 height=18> - Established 2001</p></div> <p></p> </body> </html> |