Jump to content


Photo

GIG dates like 2006-05-26, 2006-05-27, to all apprear under month headings


  • Please log in to reply
6 replies to this topic

#1 bradleyy

bradleyy
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 14 March 2006 - 03:30 PM

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 2006-05-26 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 May 26th, 2006.. but what i need is a function to help me do this below..

January
Mon 1st band name
Tue 2nd band name
Wed 3rd band name
....

February
Mon 1st band name
Tue 2nd band name
Wed 3rd band name
....

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!


<?
$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>

 <?
    } ?>


#2 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 14 March 2006 - 04:09 PM

<?
$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;
    } ?>

Then all you need to do is take the month out of the date :) i think :P
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#3 shortj75

shortj75
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationPort Huron,mi

Posted 14 March 2006 - 04:11 PM

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
The Short One

hopfully this helps if it doesn't sorry
i won't write the code for you!!! you don't learn that way

#4 bradleyy

bradleyy
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 14 March 2006 - 04:18 PM

[!--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) View Post[/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);
    $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;
    } ?>

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?



#5 bradleyy

bradleyy
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 14 March 2006 - 04:47 PM

[!--quoteo(post=354928:date=Mar 14 2006, 04:11 PM:name=shortj75)--][div class=\'quotetop\']QUOTE(shortj75 @ Mar 14 2006, 04:11 PM) View Post[/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?

#6 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 14 March 2006 - 05:13 PM

<?
$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 :)
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#7 bradleyy

bradleyy
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 14 March 2006 - 09:35 PM

[!--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) View Post[/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 :P

i'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]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users