PHP - How To Echo A Date Value As Date + 1 Month.
I am looking for a way to have my 'start_date', echo ('start_date' + 1 month). I am looking at the line that reads .... date("F Y",strtotime($row['start_date'])). Does anyone have a suggestion. The date format read, July 2014 or alphabetical full month, numerical full year. Thank you in advance.
<?php $query = sqlsrv_query($conn, $sql);if ($query === false){ exit("<pre>".print_r(sqlsrv_errors(), true));}while ($row = sqlsrv_fetch_array($query)){ echo "<tr> <td><a href='view_invoice.php?meter_id=$meter_id&subaccount=$subaccount&start_date=$row[start_date]'>$row[meter_id]</a></td> <td>" . date("F Y",strtotime($row['start_date'])) . "<td>$row[invoice_no]</td><td>" . date_format($row['invoice_date'],'Y-m-d') . "<td>$row[amount_paid]</td>" . "<td>$row[payment_date]</td>" . "<td>$row[check_number]</td>" ;}sqlsrv_free_stmt($query); ?> Edited by Butterbean, 11 January 2015 - 08:19 PM. Similar TutorialsHello. I'm new to pHp and I would like to know how to get my $date_posted to read as March 12, 2012, instead of 2012-12-03. Here is the code: Code: [Select] <?php $sql = " SELECT id, title, date_posted, summary FROM blog_posts ORDER BY date_posted ASC LIMIT 10 "; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)) { $id = $row['id']; $title = $row['title']; $date_posted = $row['date_posted']; $summary = $row['summary']; echo "<h3>$title</h3>\n"; echo "<p>$date_posted</p>\n"; echo "<p>$summary</p>\n"; echo "<p><a href=\"post.php?id=$id\" title=\"Read More\">Read More...</a></p>\n"; } ?> I have tried the date() function but it always updates with the current time & date so I'm a little confused on how I get this to work. Hi, I am having set of records, id name dob 1 philip 1278226800 2 winsent 1278216800 3 Benn 1272226800 now i want to fetch the records based on the month and listing out, can anyone help me to write for the above concept. Thanks, Hi,
I'm new to php,
I'm trying to get the month value from a date stamp (ie I have a variable with the following sort of value: 2014-08-20 07:32:20 )
how do I create a new variable with just the month values (ie 08) of the date stamp??
any help would be appreciated.
Thanks !
Hi guys, i was having an issue with dates and although it leans a bit more into MYSQL I was hoping i could get some help ive searched all over the net for this so I dont know if im not thinking on how to ask this correctly or can't find it, but ill be as detailed as possible and hope that helps.
Ok I have a table that shows when payment was received on past invoices dating back to say 1995; The company processes 'ALL' invoices every month on the 9th, so if anything comes in from the first to the ninth it will be processed that month on the ninth. If it comes in from the tenth to the thirtieth or thirty-first it will be processed the following month.
The table already has a "Received" date filed and now I want to create a column on the table called "Processed Date" (adding the column is no problem don't need help with that part) that shows me the date we processed the invoice.
I know i have to use the "Received" field (because it shows what day the invoice was put into the system) but im not sure how to format the "Processed Date" field, so say the "Received" field shows an invoice came in on '1995-05-11', I want the "Processed Date" field to display it was payed on '1995-06-09' (notice that is the following month).
I thought i would put in a visual of what I was trying to do below:
So if I pull the two columns in MYSQL from that table I would see something like this:
Received Processed Date
1996-02-03 1996-02-09
1996-03-03 1996-03-09
1996-04-11 1996-05-09
1996-05-20 1996-06-09
1996-07-13 1996-08-09
If i could get some guidance/help on this i would really appreciate it.
thanks in advance!!
JL
Hi, I'm having trouble with this: Code: [Select] $date = date('d/m/y') ; echo $date; echo "<br/>"; $date1 = strtotime('date -1 month'); echo date('Y-m-d', $date1); My result looks like this: Current Date: 19/05/11 Date minus 1 month: 1970-01-01 I want it to look like this: Current Date: 19/05/11 Date minus 1 month: 2011-04-19 date in my database is save as (dd/mm/yyyy). now i want to create sql to search for activity for chosen month..how do i extract month from (dd/mm/yyyy) and include in sql? Hello, I've been struggling for days on this problem now. And I'm getting frustrated! I know that the answer is simple, and I've done it before but I cannot figure out what I'm doing wrong. What do I want? Well, I get a date from the database in this format: YYYY-MM-DD. I first want to distract one month from that and then set in into this form: YYYY, MM, DD. I've got this but it's not working (I've tried a lot different values). $transformdate = date("Y-m-d", strtotime("-1 month", $d_datevalue)); $startpoint = str_replace("-", ", ", $transformdate); Thanks, NLCJ Hi if i have $date = "12-08-2018" or "2018-08-12" Need to subtract a month. Could this be done for day and year even? TIA Desmond. P.S. What I want to do is clear out a database table with records over a month old so today is 27th Jan 2018. I would like to create a date “2018-12-01” I can then use this in an SQL to delete all before “2018-12-01” Edited January 27, 2019 by Paul-Di have this code to set a date to the 1st of the previous month -- SELECT DATE_FORMAT(DATE_SUB(tbl_col, INTERVAL 1 MONTH), '%Y-%m-01') FROM table can it be changed to set date to first Monday in that month...? Hi Guys, Been a while since I've been on here, but I'm currently bashing my head against a wall trying to figure this one out. Basically I have a calendar that outputs Monday through Sunday, and the user clicks on a date and outputs it to the URL.... ie. ?day=$day&month=$month&year=$year. Now the next part I need to find out what day (0-6) say the 25th Feb 2011 will be wday 5... now how can I do this in code? And before anyone says why not output it to url, I cannot as the first week and last weeks use different code Cheers James Hello, I have a datepicker that when a date is selected, the post to a php file will get the sum values for that selected day, month, and year. I have the "by day" working with this... <?php $choice = (isset($_POST['choice'])) ? date("Y-m-d",strtotime($_POST['choice'])) : date("Y-m-d"); $con = mysql_connect("localhost","root","xxxxxxxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("inverters", $con); $sql = "SELECT sum(power/1000) AS choice FROM feed WHERE date = '".$choice."' group by date"; $res = mysql_query($sql) or die('sql='.$sql."\n".mysql_error()); $row = mysql_fetch_assoc($res); echo $row['choice'].'<br />'; ?> But by month and year are not clicking... Help Please Alan I have a php page where i need to list all item in a particular month.But the format for date stored is MMMM DD,yyyy that January 22, 2011. How do i extract the month name only from the above format Hi, I've got a date picker on a form which puts data into a database in the YYYY-MM-DD format. Just wondering how I could also put the name of the month (extracted from that) as well as just the year into separate columns. Ie: To use the field race_date from the form to also fill the 'race_month' and 'race_year' columns in the database. This code obviously only fills the 'race_date' column so far: Code: [Select] global $_POST; $race_date = $_POST["race_date"] ; .... $query = "INSERT INTO 10k_races (race_date, race_month, race_year)" . "VALUES ( '$race_date', '$race_month', '$race_year')"; I am using the following code to get the third sunday of every month for +6 Months from todays date. I have put together the following code which works perfectly when the date is echoed however when it comes to inserting those dates into mysql db it throws a unable to convert to string error. Im new to this and my head is in a spin as to why those dates can't be inserted if they can echoed ok. I have spent 2 days at it now and searched many forum however they seem to get side tracked from my issue (or do they)??????? I figure I can't go mixing DateTime and date() the way I have? Please help??? Code: [Select] [php] $month=date('F'); $now=date('Y-m-d'); $year=date('Y'); $num='3'; //example only this will be a $_POST value 0-3 $day='Sunday'; //example only this will be a $_POST value Monday-Sunday $start= date('Y-m-d', strtotime('+'.$num.' week '.$day.' '.$month.' '.$year.'')); if($start>$now) { $begin=strtotime('+'.$num.' week '.$day.' '.$month.' '.$year.''); } else { $d = new DateTime( $start ); $d->modify( 'first day of next month' ); $nextmonth = $d->format( 'F' ); $year = $d->format( 'Y' ); $begin=strtotime('+'.$num.' week '.$day.' '.$nextmonth.' '.$year.''); } $date=date('Y-m-d', $begin); # insert into db first occurance //mysql_select_db($database); //$query_rsFirst = "INSERT INTO event_date VALUES (NULL, '$event', '$d', '$date', '$date')"; //$rsFirst = mysql_query($query_rsFirst) or die(mysql_error()); echo $date.'<br/>'; for($i = 0; $i <= 4; $i++) { $d = new DateTime( $date ); $d->modify( 'first day of next month' ); $nextmonth = $d->format( 'F' ); $date=date('Y-m-d', strtotime('+'.$num.' week '.$day.' '.$nextmonth.' '.$year.'')); # insert into db //mysql_select_db($database); //$query_rsDate = "INSERT INTO event_date VALUES (NULL, '$event', '$d', '$date', '$date')"; //$rsDate = mysql_query($query_rsDate) or die(mysql_error()); echo $date.'<br/>'; if($nextmonth=="December") { $d = new DateTime( $date ); $d->modify( 'first day of next year' ); $year = $d->format( 'Y' ); } } [/php] Hey, I'm using a script which allows you to click on a calendar to select the date to submit to the database. The date is submitted like this: 2014-02-08 Is there a really simple way to prevent rows showing if the date is in the past? Something like this: if($currentdate < 2014-02-08 || $currentdate == 2014-02-08) { } Thanks very much, Jack I have set up a function to validate user input date in yyyy-mm-dd format taking into account the following possibilities:
the length of the month
February 29th when the year is not a leap year
When I run the code, I do not get any feedback whatsoever, when it should.
This is the code below and I would appreciate your thoughts:
if(!function_exists('checkdate')) { function checkdate($date, $checkyear, $currentmonth) { if($checkyear == 0)//if it is not a leap year { // if current month is february if($currentmonth == 2) { if(!preg_match("/^(20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|1[0-9]|2[0-8])$/", $date)) { // set error for date field return ($error = 'Invalid Date!'); } return ($error = 'valid Date!'); } // if current months are april, june, september or november elseif($currentmonth == 4 || $currentmonth == 6 || $currentmonth == 9 || $currentmonth ==11) { if(!preg_match("/^(20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|1[0-9]|2[0-8]|3[0])$/", $date)) { // set error for date field return ($error = 'Invalid Date!'); } return ($error = 'valid Date!'); } else { if(!preg_match("/^(20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-8]|3[01])$/", $date)) { // set error for date field return ($error = 'Invalid Date!'); } return ($error = 'valid Date!'); } } elseif($checkyear == 1)//if it is a leap year { // if current month is february if($currentmonth == 2) { if(!preg_match("/^(20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|1[0-9]|2[0-9])$/", $date)) { // set error for date field return ($error = 'Invalid Date!'); } return ($error = 'valid Date!'); } // if current months are april, june, september or november elseif($currentmonth == 4 || $currentmonth == 6 || $currentmonth == 9 || $currentmonth ==11) { if(!preg_match("/^(20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|1[0-9]|2[0-9]|3[0])$/", $date)) { // set error for date field return ($error = 'Invalid Date!'); } return ($error = 'valid Date!'); } else { if(!preg_match("/^(20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/", $date)) { // set error for date field return ($error = 'Invalid Date!'); } return ($error = 'valid Date!'); } } } $todate = getdate(); $currentmonth = $todate['mon']; $checkyear = date('L'); $date = 2014-02-31; echo checkdate($date, $checkyear, $currentmonth); Edited by terungwa, 26 July 2014 - 02:43 PM. Sorry for the topic title not explaining much, but I did not now how to word it! I was previous given some code at http://www.phpfreaks.com/forums/php-coding-help/streamlining-dreamweaver-generated-php-code/msg1459677/#msg1459677 that created a header every time a crtieria changed, in this case a players position. I have tried to tailor this to another page but have got it wrong somewhere. In this instance I was a change of date to be the determining factor. For example, with what I have tried so far, the output is 2011-04-02 Lowestoft Town v Tonbridge Angels 2011-04-02 Tooting & Mitcham United v Maidstone United 2011-04-02 Wealdstone v Concord Rangers 2011-04-09 Hastings United v Margate 2011-04-09 AFC Hornchurch v Carshalton Athletic 2011-04-09 Billericay Town v Aveley when I actually want 2011-04-02 Lowestoft Town v Tonbridge Angels Tooting & Mitcham United v Maidstone United Wealdstone v Concord Rangers 2011-04-09 AFC Hornchurch v Carshalton Athletic Billericay Town v Aveley I have tried to adjust the code to reflect the different query etc but something is missing. Thinking further ahead, there will also be a second criteria, in that games in different competitions could be played on the same day so I would also want to group the output by the competition ('comp' in the table) to get 2011-04-02 League Lowestoft Town v Tonbridge Angels Tooting & Mitcham United v Maidstone United Cup Wealdstone v Concord Rangers 2011-04-09 League AFC Hornchurch v Carshalton Athletic Cup Billericay Town v Aveley I would imagine that would just mean drilling down one more level in the code once I get this bit right. The tables, with a sample of data are Code: [Select] CREATE TABLE `all_games` ( `all_games_id` int(11) NOT NULL auto_increment, `date` date default NULL, `time` time default NULL, `comp` int(11) NOT NULL default '1', `round` tinyint(4) default NULL, `replay` char(1) default NULL, `home_team` int(11) NOT NULL default '1', `away_team` int(11) NOT NULL default '1', `home_goals` int(11) default NULL, `away_goals` int(11) default NULL, `home_ht` int(11) default NULL, `away_ht` int(11) default NULL, `attendance` int(11) default NULL, PRIMARY KEY (`all_games_id`) ) TYPE=MyISAM AUTO_INCREMENT=732 ; INSERT INTO `all_games` VALUES (700, '2011-04-23', '00:00:00', 1, NULL, '', 11, 20, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (701, '2011-04-23', '00:00:00', 1, NULL, '', 12, 13, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (702, '2011-04-23', '00:00:00', 1, NULL, '', 15, 22, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (703, '2011-04-23', '00:00:00', 1, NULL, '', 21, 7, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (704, '2011-04-25', '00:00:00', 1, NULL, '', 1, 14, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (705, '2011-04-25', '00:00:00', 1, NULL, '', 4, 6, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (706, '2011-04-25', '00:00:00', 1, NULL, '', 8, 15, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (707, '2011-04-25', '00:00:00', 1, NULL, '', 13, 2, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (708, '2011-04-25', '00:00:00', 1, NULL, '', 16, 21, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (709, '2011-04-25', '00:00:00', 1, NULL, '', 17, 3, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (710, '2011-04-25', '00:00:00', 1, NULL, '', 18, 9, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (711, '2011-04-25', '00:00:00', 1, NULL, '', 19, 5, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (712, '2011-04-25', '00:00:00', 1, NULL, '', 20, 12, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (713, '2011-04-25', '00:00:00', 1, NULL, '', 22, 11, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (714, '2011-04-30', '00:00:00', 1, NULL, '', 14, 18, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (715, '2011-04-30', '00:00:00', 1, NULL, '', 2, 19, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (716, '2011-04-30', '00:00:00', 1, NULL, '', 3, 22, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (717, '2011-04-30', '00:00:00', 1, NULL, '', 5, 13, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (718, '2011-04-30', '00:00:00', 1, NULL, '', 6, 8, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (719, '2011-04-30', '00:00:00', 1, NULL, '', 9, 17, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (720, '2011-04-30', '00:00:00', 1, NULL, '', 11, 7, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (721, '2011-04-30', '00:00:00', 1, NULL, '', 12, 1, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (722, '2011-04-30', '00:00:00', 1, NULL, '', 15, 20, NULL, NULL, NULL, NULL, NULL); INSERT INTO `all_games` VALUES (723, '2011-04-30', '00:00:00', 1, NULL, '', 21, 4, NULL, NULL, NULL, NULL, NULL); CREATE TABLE `competitions` ( `comp_id` int(11) NOT NULL auto_increment, `comp_name` varchar(45) default NULL, `comp_short_name` varchar(4) default NULL, `logo` varchar(255) NOT NULL default '', PRIMARY KEY (`comp_id`) ) TYPE=MyISAM AUTO_INCREMENT=8 ; INSERT INTO `competitions` VALUES (1, 'Isthmian League Premier Division', 'ILP', 'http://www.margate-fc.com/edit/news/data/upimages/images/Badges/tRymanLeague.png'); INSERT INTO `competitions` VALUES (2, 'FA Cup', 'FAC', 'http://www.margate-fc.com/edit/news/data/upimages/images/Badges/facup.png'); INSERT INTO `competitions` VALUES (3, 'FA Trophy', 'FAT', 'http://www.margate-fc.com/edit/news/data/upimages/images/Badges/fattophy.png'); INSERT INTO `competitions` VALUES (4, 'Kent Senior Cup', 'KSC', 'http://www.margate-fc.com/edit/news/data/upimages/images/Badges/kentseniorcup.png'); INSERT INTO `competitions` VALUES (5, 'Isthmian League Cup', 'ILC', 'http://www.margate-fc.com/edit/news/data/upimages/images/Badges/isthmianleaguecup.png'); INSERT INTO `competitions` VALUES (6, 'Friendly', 'FR', 'http://www.margate-fc.com/edit/news/data/upimages/images/Badges/friendly.png'); INSERT INTO `competitions` VALUES (7, 'Kent Messenger Cup', 'KMC', ''); CREATE TABLE `teams` ( `team_id` int(11) NOT NULL auto_increment, `team_name` varchar(45) default NULL, `short_name` varchar(5) default NULL, `badge` varchar(255) default NULL, `year_formed` int(11) default NULL, `nickname` varchar(255) default NULL, `previous_names` varchar(255) default NULL, `website` varchar(255) default NULL, `twitter` varchar(255) default NULL, `facebook` varchar(255) default NULL, `telephone_number` varchar(255) default NULL, `chairman` varchar(255) default NULL, `manager` varchar(255) default NULL, `home_colours` varchar(255) default NULL, `away_colours` varchar(255) default NULL, `stadium` int(11) default NULL, `2009/10` varchar(255) default NULL, PRIMARY KEY (`team_id`) ) TYPE=MyISAM AUTO_INCREMENT=74 ; INSERT INTO `teams` VALUES (1, 'Aveley', 'Ave', 'http://www.margate-fc.com/edit/news/data/upimages/images/Badges/aveley.png', 1927, 'The Millers', 'None', 'http://www.aveleyfc.net/', NULL, NULL, '01708865940', 'Graham Gennings', 'Alan Kimble', 'Black & Blue/Blue/Blue', 'Black & White/White/White', 3, 'Isthmian League Premier Division, 3rd'); INSERT INTO `teams` VALUES (2, 'Billericay Town', 'Bill', 'http://www.margate-fc.com/edit/news/data/upimages/images/Badges/billericaytown.png', 1880, 'Ricay, The Blues', 'None', 'http://www.billericaytownfc.co.uk/', 'http://twitter.com/BTFC', 'http://www.facebook.com/billericaytownfc', '01277652188', 'Steve Kent', 'Craig Edwards', 'Blue/White/Blue', 'White/Black/White', 2, 'Isthmian Premier, 13th'); INSERT INTO `teams` VALUES (3, 'Bury Town', 'Bur', 'http://www.margate-fc.com/edit/news/data/upimages/images/Badges/burytown.png', 1872, 'The Blues', 'Bury St Edmunds, Bury United', 'http://www.burytownfc.co.uk', NULL, NULL, '01277999999', 'Russell Ward', 'Richard Wilkins', 'Blue & Red/Blue/Blue', 'White/Black/White', 10, 'Southern League Division One Midlands, 1st'); INSERT INTO `teams` VALUES (4, 'Canvey Island', 'Can', 'http://www.margate-fc.com/edit/news/data/upimages/images/Badges/canveyisland.png', 1926, 'The Gulls', 'None', 'http://www.canveyislandfc.com', 'http://twitter.com/CIFC', NULL, NULL, 'George Frost', 'John Batch', 'Yellow/Blue/White', 'White/White/White', 11, 'Isthmian League Premier Division, 16th'); INSERT INTO `teams` VALUES (5, 'Carshalton Athletic', 'Car', 'http://www.margate-fc.com/edit/news/data/upimages/images/Badges/carshaltonathletic.png', 1905, 'The Robins', 'Mill Lane Misson', 'http://www.carshaltonathletic.co.uk/', 'http://twitter.com/carshaltonath', NULL, '02086428658', 'Harry Driver', 'Mark Butler', 'Red/Red/Red', 'Maroon/White/Maroon', 9, 'Isthmian League Premier Division, 17th'); INSERT INTO `teams` VALUES (6, 'Concord Rangers', 'Con', 'http://www.margate-fc.com/edit/news/data/upimages/images/Badges/concordrangers.png', 1967, 'Beach Boys', 'None', 'http://www.concordrangers.co.uk/', 'http://twitter.com/ConcordRangers', NULL, '01268691780', 'Antony Smith', 'Danny Scopes / Danny Cowley', 'Yellow/Blue/Blue', 'TBA', 12, NULL); INSERT INTO `teams` VALUES (7, 'Cray Wanderers', 'Cray', 'http://www.margate-fc.com/edit/news/data/upimages/images/Badges/craywanderers.png', 1860, 'The Wands', 'None', 'http://www.craywands.co.uk', 'http://twitter.com/craywanderers', NULL, '02084605291', 'Gary Hillman', 'Ian Jenkins', 'Amber/Black/Amber', 'Blue/White/White', 13, 'Isthmian League Premier Division, 15th'); INSERT INTO `teams` VALUES (8, 'Croydon Athletic', 'Croy', 'http://www.margate-fc.com/edit/news/data/upimages/images/Badges/croydonathletic.png', 1986, 'The Rams', 'Wandsworth & Norwood', 'http://croydonathletic.net', NULL, NULL, '0208664834', 'TBA', 'Dave Garland & Bob Langford', 'Maroon & White/Maroon/Maroon', 'Yellow/Blue/Blue', 14, 'Isthmian League Division One South, 1st'); INSERT INTO `teams` VALUES (9, 'Folkestone Invicta', 'Fol', 'http://www.margate-fc.com/edit/news/data/upimages/images/Badges/folkestoneinvicta.png', 1936, 'Invicta, The Seasiders', 'None', 'http://www.folkestoneinvicta.co.uk/', 'http://twitter.com/FIFC', NULL, '01303257461', 'TBA', 'Neil Cugley', 'Amber/Black/Amber', 'Red/White/Red', 15, 'Isthmian League Division One South, 2nd'); INSERT INTO `teams` VALUES (10, 'Grays Athletic', 'Gra', 'N/A', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); INSERT INTO `teams` VALUES (11, 'Harrow Borough', 'Har', 'http://www.margate-fc.com/edit/news/data/upimages/images/Badges/harrowborough.png', 1933, 'The Boro, The Reds', 'Roxoinian, Harrow Town', 'http://www.harrowboro.com/', 'http://twitter.com/harrowboro_fc', NULL, '08706091959', 'Peter Rogers', 'David Howell', 'Red/Red/Red', 'White/White/Black', 16, 'Isthmian League Premier Division, 14th'); INSERT INTO `teams` VALUES (12, 'Hastings United', 'Has', 'http://www.margate-fc.com/edit/news/data/upimages/images/Badges/hastingsunited.png', 1894, 'The Arrows, The U''s', 'Hastings Town, Hastings & St. Leonards', 'http://www.hastingsunitedfc.co.uk/', 'http://twitter.com/hastingsufc', NULL, '01424444635', 'David Walter', 'Tony Dolby', 'Maroon/Maroon/Maroon', 'White/White/White', 17, 'Isthmian League Premier Division, 7th'); INSERT INTO `teams` VALUES (13, 'Hendon', 'Hen', 'http://www.margate-fc.com/edit/news/data/upimages/images/Badges/hendon.png', 1908, 'The Greens, The Dons', 'Christ Church Hampstead, Hampstead Town, Hampstead, Golders Green', 'http://www.hendonfc.net/', 'http://twitter.com/HendonFC', NULL, '02089083553', 'TBA', 'Gary McCann', 'Green/Green/Green', 'Blue/Blue/Blue', 18, 'Isthmian League Premier Division, 10th'); INSERT INTO `teams` VALUES (14, 'AFC Hornchurch', 'AFC', 'http://www.margate-fc.com/edit/news/data/upimages/images/Badges/afchornchurch.png', 1923, 'The Urchins', 'Upminster Wanderers, Hornchurch & Upminster', 'http://www.afchornchurch.com/', 'http://twitter.com/AFCHornchurch', 'http://www.facebook.com/AFCHornchurch', '01708220080', 'TBA', 'Colin McBride', 'Red & White/Black/Red', 'Blue & White/Blue/Blue', 1, 'Isthmian League Premier Division, 9th'); INSERT INTO `teams` VALUES (15, 'Horsham', 'Hor', 'http://www.margate-fc.com/edit/news/data/upimages/images/Badges/horsham.png', 1871, 'The Hornets', 'None', 'http://www.hornetsreview.co.uk/', NULL, NULL, '01403266888', 'Kevin Borrett', 'John Maggs', 'Yellow & Green/Yellow/Yellow', 'Blue/Black/White', 19, 'Isthmian League Premier Division,11th'); The query is $all_games = mysql_query("SELECT *, HT.team_name as HomeTeam, VT.team_name as AwayTeam, COMP.comp_short_name as CP FROM all_games JOIN teams as HT ON all_games.home_team = HT.team_id JOIN teams as VT ON all_games.away_team = VT.team_id JOIN competitions as COMP ON all_games.comp = COMP.comp_id ORDER BY date ASC "); if (!$all_games) { die("Query to show fields from table failed"); And the code that echoes the right values, but does not seperate the the dates is if($all_games) { if(mysql_num_rows($all_games)) { $lastdate = 0; while ($row_all_games = mysql_fetch_assoc($all_games)) { // when the date changes output a new heading if($lastdate = $row_all_games['date']) { echo "<h1>".strtoupper($row_all_games['date'])."</h1>"; $lastdate = $row_all_games['date']; } echo $row_all_games['HomeTeam']." v ".$row_all_games['AwayTeam']; } } else { echo "No results!"; } } I must admit that I have tried a few variations but the nearest I have got is for the page to echo "No results!" I may be a fraction off getting it right or a million miles away so if anyone can give any pointers I will be very grateful. Thanks in advance Steve Hello fellow php friends, Im having abit of trouble trying to echo out a statement at certain times of the day. for example how would you echo out 'Good Morning' between the times of 01am to 11.59am then echo out 'Good afternoon' between times of 12pm and 6pm and so on. Please help!!!!! What I'm basically trying to accomplish is, that the datetime of the user posted information is registered with the Now() function in the query, BUT that the user entered information gets echo'd out with the Date showing ONLY. What I have is this: -Just as an example- INSERT INTO db (date_created) VALUES (now()) while ($row = mysqli_fetch_array($data)) { echo '<tr><td>' . $row['date_created'] . '</td></tr>'; } mysqli_close($dbc); With this way of course I get Date and Time showcased just like it's inserted into the DB. What would be a legit way of showcasing just date. Thanks for help. EDIT: or is there a better way than using now() to showcase the date when the user entered information was posted? Hello, I want to display a weekly events day and time. This event will always be on Saturday @ 10:45 am however, I want to output: 2011-09-17 10:45 then when that date is passed - I want it to change to the next Saturday: 2011-09-21 10:45 etc. Any ideas? |