bradleyy Posted March 14, 2006 Share Posted March 14, 2006 Hi!Basically the title says it all.. i am making a website for a music venue in Leeds, the UK.I am fine using PHP, and generally never have to get help anymore. However, this latest function i need is a little above me, and it seems tricky to Google and answer and also harder to find one in the books i have.SO, the gig dates, usually one for every night of the year, are stored in [b]2006-05-26[/b] for example. As you can see at [a href=\"http://www.josephswell.co.uk/?pg=g\" target=\"_blank\"]http://www.josephswell.co.uk/?pg=g[/a], i'm fine converting them to [b]May 26th, 2006[/b].. but what i need is a function to help me do this below..[b]January[/b]Mon 1st [i]band name[/i]Tue 2nd [i]band name[/i]Wed 3rd [i]band name[/i]....[b]February[/b]Mon 1st [i]band name[/i]Tue 2nd [i]band name[/i]Wed 3rd [i]band name[/i]....I hope this makes sense!What i'll do, is post what i use at the moment and hopefully someone can link me to a page or give me a little help on how to do this![code]<?$today = date("Y-m-d");$result = mysql_query("SELECT * FROM gigs WHERE date >= '$today' ORDER BY date ASC"); while($myrow = mysql_fetch_assoc($result)) { $date = $myrow['date']; list($year, $month, $day) = split("-", $date); $date = date('M d, Y', mktime(0, 0, 0, $month, $day, $year)); ?><? echo $date; ?> - <a href="?pg=gi&id=<? echo $myrow[id]; ?>"><? echo $myrow['headline']; ?></a></b><br> <? } ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/4932-gig-dates-like-2006-05-26-2006-05-27-to-all-apprear-under-month-headings/ Share on other sites More sharing options...
shocker-z Posted March 14, 2006 Share Posted March 14, 2006 [code]<?$today = date("Y-m-d");$result = mysql_query("SELECT * FROM gigs WHERE date >= '$today' ORDER BY date ASC");$month=1; while($myrow = mysql_fetch_assoc($result)) { $date = $myrow['date']; list($year, $month, $day) = split("-", $date); $date = date('M d, Y', mktime(0, 0, 0, $month, $day, $year)); if ($month != $lastmonth) { echo("<B>$month</B><Br>"); }?><? echo $date; ?> - <a href="?pg=gi&id=<? echo $myrow[id]; ?>"><? echo $myrow['headline']; ?></a></b><br><?$lastmonth=$month; } ?>[/code]Then all you need to do is take the month out of the date :) i think :P Quote Link to comment https://forums.phpfreaks.com/topic/4932-gig-dates-like-2006-05-26-2006-05-27-to-all-apprear-under-month-headings/#findComment-17401 Share on other sites More sharing options...
shortj75 Posted March 14, 2006 Share Posted March 14, 2006 ok try this<?$today = date("Y-m-d");$result = mysql_query("SELECT * FROM gigs WHERE date='$today' ORDER BY date ASC"); while($myrow = mysql_fetch_array($result)) { $date = $myrow['date']; list($year, $month, $day) = split("-", $date); $date = date('M d, Y', mktime(0, 0, 0, $month, $day, $year)); echo "$date - <a href="?pg=gi&id= $myrow[id]>$myrow[headline]</a></b><br>"; } ?>hopfully this helps Quote Link to comment https://forums.phpfreaks.com/topic/4932-gig-dates-like-2006-05-26-2006-05-27-to-all-apprear-under-month-headings/#findComment-17402 Share on other sites More sharing options...
bradleyy Posted March 14, 2006 Author Share Posted March 14, 2006 [!--quoteo(post=354927:date=Mar 14 2006, 04:09 PM:name=shocker-z)--][div class=\'quotetop\']QUOTE(shocker-z @ Mar 14 2006, 04:09 PM) [snapback]354927[/snapback][/div][div class=\'quotemain\'][!--quotec--][code]<?$today = date("Y-m-d");$result = mysql_query("SELECT * FROM gigs WHERE date >= '$today' ORDER BY date ASC");$month=1; while($myrow = mysql_fetch_assoc($result)) { $date = $myrow['date']; list($year, $month, $day) = split("-", $date); $date = date('M d, Y', mktime(0, 0, 0, $month, $day, $year)); if ($month != $lastmonth) { echo("<B>$month</B><Br>"); }?><? echo $date; ?> - <a href="?pg=gi&id=<? echo $myrow[id]; ?>"><? echo $myrow['headline']; ?></a></b><br><?$lastmonth=$month; } ?>[/code]Then all you need to do is take the month out of the date :) i think :P[/quote]Dude!it looks like you've pretty much helped me out!go here: [a href=\"http://josephswell.co.uk/x/?pg=g\" target=\"_blank\"]http://josephswell.co.uk/x/?pg=g[/a]how would i make it so instead of it saying 05 etc for month, May? Quote Link to comment https://forums.phpfreaks.com/topic/4932-gig-dates-like-2006-05-26-2006-05-27-to-all-apprear-under-month-headings/#findComment-17406 Share on other sites More sharing options...
bradleyy Posted March 14, 2006 Author Share Posted March 14, 2006 [!--quoteo(post=354928:date=Mar 14 2006, 04:11 PM:name=shortj75)--][div class=\'quotetop\']QUOTE(shortj75 @ Mar 14 2006, 04:11 PM) [snapback]354928[/snapback][/div][div class=\'quotemain\'][!--quotec--]ok try this<?$today = date("Y-m-d");$result = mysql_query("SELECT * FROM gigs WHERE date='$today' ORDER BY date ASC"); while($myrow = mysql_fetch_array($result)) { $date = $myrow['date']; list($year, $month, $day) = split("-", $date); $date = date('M d, Y', mktime(0, 0, 0, $month, $day, $year)); echo "$date - <a href="?pg=gi&id= $myrow[id]>$myrow[headline]</a></b><br>"; } ?>hopfully this helps[/quote]thanks for having a look, but i want to make a big list, won't that one just show one listing? Quote Link to comment https://forums.phpfreaks.com/topic/4932-gig-dates-like-2006-05-26-2006-05-27-to-all-apprear-under-month-headings/#findComment-17418 Share on other sites More sharing options...
shocker-z Posted March 14, 2006 Share Posted March 14, 2006 <?$today = date("Y-m-d");$result = mysql_query("SELECT * FROM gigs WHERE date >= '$today' ORDER BY date ASC");$month=1; while($myrow = mysql_fetch_assoc($result)) { $date = $myrow['date']; list($year, $month, $day) = split("-", $date); $monthname=date('M', mktime(0, 0, 0, $month, $day, $year)); $date = date('d', mktime(0, 0, 0, $month, $day, $year)); if ($year != $lastyear) { echo("<B>Year $year</B><Br>"); } if ($month != $lastmonth) { echo("<B>$monthname</B><Br>"); }?><? echo $date; ?> - <a href="?pg=gi&id=<? echo $myrow[id]; ?>"><? echo $myrow['headline']; ?></a></b><br><?$lastmonth=$month;$lastyear=$year; } ?>that should show year, month and then the day of each month :) Quote Link to comment https://forums.phpfreaks.com/topic/4932-gig-dates-like-2006-05-26-2006-05-27-to-all-apprear-under-month-headings/#findComment-17425 Share on other sites More sharing options...
bradleyy Posted March 14, 2006 Author Share Posted March 14, 2006 [!--quoteo(post=354951:date=Mar 14 2006, 05:13 PM:name=shocker-z)--][div class=\'quotetop\']QUOTE(shocker-z @ Mar 14 2006, 05:13 PM) [snapback]354951[/snapback][/div][div class=\'quotemain\'][!--quotec--]<?$today = date("Y-m-d");$result = mysql_query("SELECT * FROM gigs WHERE date >= '$today' ORDER BY date ASC");$month=1; while($myrow = mysql_fetch_assoc($result)) { $date = $myrow['date']; list($year, $month, $day) = split("-", $date); $monthname=date('M', mktime(0, 0, 0, $month, $day, $year)); $date = date('d', mktime(0, 0, 0, $month, $day, $year)); if ($year != $lastyear) { echo("<B>Year $year</B><Br>"); } if ($month != $lastmonth) { echo("<B>$monthname</B><Br>"); }?><? echo $date; ?> - <a href="?pg=gi&id=<? echo $myrow[id]; ?>"><? echo $myrow['headline']; ?></a></b><br><?$lastmonth=$month;$lastyear=$year; } ?>that should show year, month and then the day of each month :)[/quote]you are so awesome :pi'm at work now, can't fix it till tomorrow, so i'll update with solved etc tomorrow!BTW - i gave the wrong URL in 1st post - [a href=\"http://www.josephswell.co.uk/x/\" target=\"_blank\"]http://www.josephswell.co.uk/x/[/a] Quote Link to comment https://forums.phpfreaks.com/topic/4932-gig-dates-like-2006-05-26-2006-05-27-to-all-apprear-under-month-headings/#findComment-17540 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.