Jump to content

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


bradleyy

Recommended Posts

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]
Link to comment
Share on other sites

[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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

[!--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?

Link to comment
Share on other sites

[!--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?
Link to comment
Share on other sites

<?
$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 :)
Link to comment
Share on other sites

[!--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 :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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.