PHP - Help With Getting Prior Month...
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")); Similar TutorialsHi.. I need help in getting the 3 Months Name from my table field FromMonth and ToMonth. Here is the scenario. First, I select FromMonth and ToMonth. Ex. FromMonth = 5 ToMonth = 7 So it means FromMonth is May ToMonth is July. Now I save the MonthNumber to my database: table- so_month FromMonth = 5 ToMonth = 7 Now I need to get the between Months Name from FromMonth to ToMonth which are (May, June, July). How does it possible? Thank you so much. Trying to get the below to generate the month in word form from a numeric entry in a database. Code: [Select] elseif($_GET['rma']=="calander"){ $sql101010="SELECT DISTINCT rma_year_issued FROM $tbl_name4 ORDER BY rma_year_issued"; $result101010=mysql_query($sql101010); while($row101010=mysql_fetch_array($result101010)){ extract($row101010); $content.='<a href="./acp_admincp.php?rma=calander&year='.$rma_year_issued.'">'.$rma_year_issued.'</a> <br />'; } if(isset($_GET['year'])){ $logout.=' | <a href="./acp_admincp.php?rma=calander">Back to RMA Calander</a>'; $rma_year_issued=$_GET['year']; $sql111010="SELECT DISTINCT rma_month_issued FROM $tbl_name4 WHERE rma_year_issued='$rma_year_issued' ORDER BY rma_month_issued"; $result111010=mysql_query($sql111010); while($row111010=mysql_fetch_array($result111010)){ extract($row111010); $months = array('Janurary', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); for($i=0; $i <=11; $i++){ if($rma_month_issued=$i){ $rma_month_issued2=$months[$i]; } } $content=""; $content.='<a href="./acp_admincp.php?rma=calander&year='.$rma_year_issued.'&month='.$rma_month_issued.'">'.$rma_month_issued2.'</a> <br />'; } } } Basically in the data base I may have 2,5,7 under the year 2011. I want to get the numeric months into words for use in the text of the link. The above is returning December even though the entry in the database is 5. So I am creating a list of events. There will be a drop down menu to change between months. I only want the months to be listed if an event during that month exists. So if I have events listed for September and November, list only September and November, skipping October. Any idea on how to approach this or if there are any functions for such a thing? 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> Hi
I'm have a PHP form that submits to a MYSQL database and I'm trying to make it so when any form input field is empty the user gets a message below that field and the data isn't submitted. I can't seem to get it work though?
<?php // submit data to database if (isset($_POST['submit'])) { // assign variable names to name attributes from the form $firstname = $_POST['first-name']; $email = $_POST['email']; // This is the attempted validation code if(empty($firstname)) { $error= "<br>- Please enter your firstname"; } if(empty($email)) { $error="<br>- Please enter your email"; } if ($error) { $result="<p class='alert error'>There is an error. Please correct the following: {$error}</p>"; } else { // This is when the data is submitted $query = "INSERT INTO users(firstname, email) VALUES(?,?)"; $stmt = $connection->prepare($query); $stmt->bind_param("ss", $f, $e); $f = $firstname; $e = $email; $stmt->execute(); $stmt->close(); $connection->close(); header("Location: index.php"); // makes page refresh after query so new records show in HTML table } } ?>
I want to remove the HTTP:// or HTTPS:// from the insert into the DB. The Viewer may put just www, or copy the entire URL with the HTTP:// or HTTPS://
I tried using the preg-replace but couldn't seem to get it to work.
Any other recommendation?
Thanks in advance,
Mike
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 Hey everyone, so im trying to utilize a systems OPTION command send prior to the POST command, the OPTION command will for example state that it would like to request specific headers. im trying to perform this to get the headers needed before the POST command im trying to execute, the values are required for the POST command i need to perform to get a response. The URL in question would be: https://media-entitlement.mlb.com/api/v3/jwt?os=windows&did=ffeae86c-9447-4bac-a021-caad0c02c605&appname=mlbtv_web Request method: OPTIONS (to get required headers):
Host: media-entitlement.mlb.com then a post command is performed just after which retrieves the values originally requested by the OPTIONS command prior to the POST:
Host: media-entitlement.mlb.com
Now Generally speaking, i fully understand their authorization etc. but this specific set of values seem only used in this one situation, they use bam-sdk which i understand pretty well. but needless to say this authorization bearer, and api-key value only seem generated via the initial OPTIONS grab in browser. so in summary i need to understand how these OPTIONS commands can be utilized to store the required headers as a variable which can be used in the POST command. Thanks in advance for your time and energy responding. mosb3rgler Edited June 14, 2019 by mosb3rglertypo Hello everyone I am coding a membership system for my usersystem on my website and I needed a little help. I have searched around quite a bit and can't find a working code. In my database I have the date the VIP was purchased and I was wondering if anyone had a code which would check if they've had VIP for over a month and if so, delete it from the database. I'm new-ish to MySQL and PHP and can't seem to code a working one. I'm trying to get a total number from the db where the month is the same and the ip is different. This is a stats script that someone else wrote, and I'm just trying to get a month-to-month total. Right now, it pulls the information out and displays the month with how many different ips came that month, the problem is, it lists like this: June - 41 - 41 June - 1 - 1 June - 1 - 1 June - 1 - 1 June - 1 - 1 June - 1 - 1 June - 9 - 9 June - 2 - 2 June - 2 - 2 June - 2 - 2 June - 1 - 1 June - 3 - 3 June - 2 - 2 June - 4 - 4 June - 1 - 1 June - 13 - 13 June - 154 - 154 what I need to do is grab all those numbers and give a total for that month, in this case, June. This is my query Code: [Select] $query = "SELECT date, COUNT(referrer)'referrer' FROM app_analytics WHERE appid = $userid AND date BETWEEN '" .$y_month . "' AND '" . $t_month . "' GROUP BY referrer ORDER BY date"; Can anybody help out? Thanks in advance Hello, Doing a little calendar where days are incremented as variable $i formatted like 'j' or single digit numbers 1,2,3 etc. (The calendar works fine) However for querying DB tables I need the day formatted as 'd' or 01,02,03 etc. so on any day I need to make this conversion. I can't find an easy solution though there must be one. Thanks in advance. Code: [Select] <?php //test day $i=7; $day=date('d', mktime($i)); echo "$day"; //Should be 07 ?> I am trying to compare values and if the month is not of 2 digits then the comparison goes wrong. Here is some hacked crap that doesn't work. if (strlen($_POST['m'] <= 1)){$month = "0".$_POST['m'];}else{$month = $_POST['m'];} if (strlen($_POST['d'] <= 1)){$day = "0".$_POST['d'];}else{$day = $_POST['d'];} <form> function GetDays(){ $Listd = '<select name="d">'; if (isset($_POST['d'])){$Listd .='<option value="'.$_POST['d'].'">'.$_POST['d'].'</option>';} for ($x = 1; $x <= date('d'); $x++) $Listd .= '<option value="'.$x.'">'.$x.'</option>'; $Listd .= '</select>'; return $Listd; } function GetMonths(){ $Listm = '<select name="m">'; if (isset($_POST['m'])){$Listm .='<option value="'.$_POST['m'].'">'.$_POST['m'].'</option>';} for ($x = 1; $x <= date('m'); $x++) $Listm .= '<option value="'.$x.'">'.$x.'</option>'; $Listm .= '</select>'; return $Listm; } Here is what I am comparing: Now: 201012141292327875 Submitted: 201110101292353200 // 2 digit month/day Now: 201012141292327984 Submitted: 2011991292353200 // not 2 digits month/day 2 hours is enough for me...can someone shed some light on this for me please? Hello. I want to generate the initial of the day of all the days of a chosen month. Meaning, if I choose this month it will give me: TFSSMTWTFSSMTWTFSSMTWTFSSMTWTF Is that clear? Can anybody help me? thanks! Hi, this one has me stumped! For some reason February refuses to show up in my calender, that is, month 2 reads as march as well as month 3 (being correct). Here is my code which is fine except for this silly bug: $month = $_GET['month'] ; $year = $_GET['year'] ; if(!$month) $month = date('n') ; if(!$year) $year = date('Y') ; $days = cal_days_in_month(CAL_GREGORIAN, $month, $year) ; echo "<div style='width:100%;text-align:center;font-size:1.3em;font-weight:bold;'>" ; if($month == 1) echo "<a href=\"?month=12&year=" . ($year-1) ; else echo " <a href=\"?month=" . ($month-1) . "&year=" . $year ; echo "\"><img style='border:none;' width='16' src='prev-month.png' /></a>" ; echo " Classes for " . date("F, Y", strtotime("$year-$month")) . "\n" ; if($month == 12) echo "<a href=\"?month=1&year=" . ($year+1) ; else echo " <a href=\"?month=" . ($month+1) . "&year=" . $year ; echo "\"><img style='border:none;' width='16' src='next-month.png' /></a>\n" ; echo "</div>\n" ; for($i=1;$i < 8;$i++) { // Create day headers... echo "<div style='float:left;width:110px;margin:20px 5px 0px 5px;text-align:center;background:#1552ff;color:white;border:1px solid #155BFF;'>" . date("l", strtotime("$year-$month-$i")) . "</div>\n" ; } for($i=1; $i < $days+1;$i++) { // Create days... $result = mysql_query("SELECT * FROM classes WHERE DAY(classDate) = '$i' AND MONTH(classDate) = '$month' AND YEAR(classDate) = '$year'")or die(mysql_error()) ; $classCount = mysql_num_rows($result) ; while($row = mysql_fetch_assoc($result)) { $classes .= $row['title'] . "<br />" ; } echo "<div style='float:left;width:104px;height:104px;margin:0px 5px 0px 5px; border:1px solid #155BFF;border-top:none;cursor:pointer;padding:3px;' onmouseover=\"this.style.background='#ffbdec';\" onmouseout=\"this.style.background='none';\" title=\"" . str_replace('<br />', "\n\n", $classes) . "\" alt=\"" . str_replace('<br />', "\n\n", $classes) . "\">\n" ; echo "<div style='float:left;height:84px;width:104px;'>\n" ; echo "<span style='font-weight:bold;'>$i</span><br />\n" ; echo "<span style='font-size:0.7em;'>" ; echo $classes ; echo "</span></div>\n" ; echo "<div style='float:left;height:20px;width:104px;text-align:center;'>\n" ; echo "<a href='#' style='font-size:0.7em;'>click to book a class</a>\n" ; echo "</div>\n" ; echo "</div>\n" ; $classes = '' ; } working example he www.caketopper.co.uk/2011/class-schedule.php I need to find the last Friday of each month and determine the start and end dates of each month based on the last Friday. So, for September, the last Friday was the 27th, that means Saturday the 28th will be the last day of September. September 29 will then start the first day of October.... October 25 is the last Friday in October, so Saturday October 26 will close out October..... Sun Oct 27 starts November, etc... 7/28 - 8/31 9/1 - 9/28 9/29 - 10/26 10/27 - 11/30 I can build a table and manually key in the start and end dates then query as needed, but if there is a way to do it on the fly, I'd rather do it in php to eliminate mistakes.
Below is the code I'm currently using to find the first and last day of each calendar month, but I'll need to convert this to find the fiscal month based on the last Saturday of each month. And go back a few years in the option select. <select name="dateselect" id="dateselect"> <?php $today = date("Y-m-d"); $monthbegin = date("Y-m-d",strtotime('first day of this month', strtotime($today))); for( $i= 0 ; $i <= 52 ; $i++ ) { if($i == 0){ $monthselect = date('Y-m-d',strtotime($monthbegin)); $monthdisplay = date('F Y',strtotime($monthbegin)); echo '<option ' . ($i == 0 ? 'selected=\'selected\'' : '') . ' value="' . $monthselect . '" >' . $monthdisplay . '</option>'; } else{ $monthselect = date('Y-m-d',strtotime('-'."$i".' months',strtotime($monthbegin))); $monthdisplay = date('F Y',strtotime('-'."$i".' months',strtotime($monthbegin))); echo '<option ' . ($i == 0 ? 'selected=\'selected\'' : '') . ' value="' . $monthselect . '" >' . $monthdisplay . '</option>'; } } ?> </select> $begin_date = $_GET["dateselect"]; $end_date = date("Y-m-t", strtotime($begin_date)); Edited November 8, 2019 by jakebur01 delete Hi, I m trying to extract data by month from my date table. my date format 2011-03-28 my query $sql = "select * from table WHERE MONTH(date) = 03 " Now problem is i have many records in 3rd month but it only display the first row with above $sql. How can i see all month records. Thanks Thanks to aleX_hill and RussellReal for the help so far. I'm trying to utilise the code before to find the next month. However, it needs to be used with the current year. So I altered the below <?php $nextMonth = date("m") + 1; $daysInNextMonth = date("t",mktime(0,0,0,$nextMonth)); echo $daysInNextMonth;?> to #NEXT MONTH $nextMonth = date("m") + 1; echo $nextMonth; $daysInNextMonth = date("t",mktime(0,0,0,$nextMonth)); echo $daysInNextMonth ; $year = date("o"); echo $year; I can then pass it into my url query like so: <a href="<?php echo $url_path; ?>after=<?php echo $year; ?>-<?php echo $nextMonth; ?>-01&before=<?php echo $year; ?>-<?php echo $nextMonth; ?>-<?php echo $daysInNextMonth; ?>">Next Month</a> Brilliant I thought, until it comes to December 2010, the next month needs to be January 2011. Now I'm bamboozled. How do I get around this one? Many thanks, your help is always appreciated! I'm trying to get a bar graph from total number of hit on a month to month basis. Everything works out find, except the bar graph is only showing 1 month, not everything that's being pulled out of the db. Can anybody look and see what I'm doing wrong? Code: [Select] $userid = '44'; $t_month = date("Y-m-d h:i:s"); $y_month = date("Y-m-d h:i:s", strtotime("-1 Year")); //Grabs Unique Visitors to App Page $query = "SELECT CONCAT_WS(' ', YEAR(date), MONTHNAME(date)) AS RptDate, COUNT(DISTINCT referrer) 'referrer' FROM app_analytics WHERE appid = $userid AND date BETWEEN '" .$y_month."' AND '" .$t_month."' GROUP BY CONCAT_WS(' ', YEAR(date), MONTHNAME(date)) ORDER BY YEAR(date), MONTH(date)"; $result = mysql_query($query) or die(mysql_error()); //$totals = array(); while($row = mysql_fetch_array( $result )){ $months = date("M", strtotime($row['RptDate'])); $ip = $row['referrer']; $values = array("$months" => $ip); $img_width=450; $img_height=300; $margins=20; # ---- Find the size of graph by substracting the size of borders $graph_width=$img_width - $margins * 2; $graph_height=$img_height - $margins * 2; $img=imagecreate($img_width,$img_height); $bar_width=20; $total_bars=count($values); $gap= ($graph_width- $total_bars * $bar_width ) / ($total_bars +1); # ------- Define Colors ---------------- $bar_color=imagecolorallocate($img,0,64,128); $background_color=imagecolorallocate($img,240,240,255); $border_color=imagecolorallocate($img,200,200,200); $line_color=imagecolorallocate($img,220,220,220); # ------ Create the border around the graph ------ imagefilledrectangle($img,1,1,$img_width-2,$img_height-2,$border_color); imagefilledrectangle($img,$margins,$margins,$img_width-1-$margins,$img_height-1-$margins,$background_color); # ------- Max value is required to adjust the scale ------- $max_value=max($values); $ratio= $graph_height/$max_value; # -------- Create scale and draw horizontal lines -------- $horizontal_lines=20; $horizontal_gap=$graph_height/$horizontal_lines; for($i=1;$i<=$horizontal_lines;$i++){ $y=$img_height - $margins - $horizontal_gap * $i ; imageline($img,$margins,$y,$img_width-$margins,$y,$line_color); $v=intval($horizontal_gap * $i /$ratio); imagestring($img,0,5,$y-5,$v,$bar_color); } # ----------- Draw the bars here ------ for($i=0;$i< $total_bars; $i++){ # ------ Extract key and value pair from the current pointer position list($key,$value)=each($values); $x1= $margins + $gap + $i * ($gap+$bar_width) ; $x2= $x1 + $bar_width; $y1=$margins +$graph_height- intval($value * $ratio) ; $y2=$img_height-$margins; imagestring($img,0,$x1+3,$y1-10,$value,$bar_color); imagestring($img,0,$x1+3,$img_height-15,$key,$bar_color); imagefilledrectangle($img,$x1,$y1,$x2,$y2,$bar_color); } header("Content-type:image/png"); imagepng($img); } Thanks in advance
I'm trying to parse multiple rss feeds and only show and save items from the last month, but i can't get it to work. I've tried this: $pubdate = date("Y-m-d", strtotime($item->pubDate)); if (date($pubdate, strtotime(" -1 month")))
|