NineChime forum

Furry stuff, oekaki stuff, and other stuff.

You are not logged in.

#1 09-26-2009 23:24:59

Silverpaws006
New member

Birthdays for the month!

Okay first, since this is my first post after registering... intro xD
I'm Silverpaws006/Char of URKaki.
uhh, I'm not really that good with PHP...
I made this script for our oekaki and just thought others might like it too :3

This displays the people with birthdays for the month smile
you can paste it on the notice:

P.S. I'm thinking up of more scripts when I have free time, so uhh,
to the admin: asking permission if I could post more soon?


Code:

<?php
//===========================================================================
// BIRTHDAYS START
// by Silverpaws006/Char of http://www.auropaws.com/
//===========================================================================
?>

<div style="padding:5px;width:400px;border:2px solid #ff6060;background:#ffffcc;color:#000000;">
<b>:: Birthdays this month ::</b>
<br/><br/>

<div style="text-align:left;">

<?php
$monthnow = date("m",time());
$query_dates = mysql_query("SELECT usrname, age FROM op_oekaki ORDER BY age ASC");
while($array = mysql_fetch_array($query_dates)) {

    $date = $array[1];
    $get_month = substr($date,5,2);

    if($monthnow == $get_month) {

        $to_timestamp = strtotime($date);
        $to_date = date("M j",$to_timestamp);
        $linkname = "<a onclick=\"openWindow('profile.php?user=$array[0]', 400, 600); return false\" href=\"profile.php?user=$array[0]\" style='color:#000000;'>$array[0]</a>
        ";
        echo ($to_date . " - " . $linkname . "<br/>");

    }


    if(!$array) {
        echo("No birthdays this month.");
    }

}
?>
</div>



</div>

<?php
//===========================================================================
// BIRTHDAYS END
//===========================================================================
?>

Last edited by Silverpaws006 (09-26-2009 23:27:50)


Heya, I'm Silverpaws006, but please just call me Char smile
Auropaws | Umbreon's Rift Oekaki | Deviantart | Twitter

Offline

#2 09-27-2009 00:59:47

rainbow
Member

Re: Birthdays for the month!

Great idea! I might consider trying out this script on my oekaki board very soon to see if it works. smile

Offline

#3 09-27-2009 21:43:08

Waccoon
Administrator

Re: Birthdays for the month!

One nit:  you should use mysql_fetch_row() instead of mysql_fetch_array().

Code:

$result = mysql_query ("SELECT `get`, `some`, `names` FROM `op_table` ORDER BY `ID` DESC");

$row = mysql_fetch_array($result);
echo ($row['names']);

$row = mysql_fetch_row($result);
echo ($row[3]);

$row = mysql_fetch_array($result, MYSQL_ASSOC);
echo ($row['names']);

$row = mysql_fetch_array($result, MYSQL_NUM);
echo ($row[3]);

Using mysql_fetch_array() will work if your server has notices disabled, but fetching a row is preferred.

Offline

#4 09-27-2009 23:49:28

Silverpaws006
New member

Re: Birthdays for the month!

Umm, I used mysql_fetch_array 'cause I'm fetching more than one row,
come to think of it, I use that all the time xD

I'm not sure of it's difference with fetch_row and fetch_assoc really,
but I think I read an article saying fetch_array is faster(?) and kinda like a combination of both.

Well just in case, if the script doesn't work, people can change mysql_fetch_array to mysql_fetch_row.


Heya, I'm Silverpaws006, but please just call me Char smile
Auropaws | Umbreon's Rift Oekaki | Deviantart | Twitter

Offline

Board footer

Yep, still running PunBB
© Copyright 2002–2008 PunBB