Jump to content

date functionality


KillerWolf

Recommended Posts

hey guys iam new to php just started about 1 month ago, noticed this forum was very popular found lots of answers to problems i was having but now iam stuck.  what iam trying to do is use the date function along with an array to output a new hyperlink every month.  what i understand so far is that i need an array of course, and then also declare the getdate() method. what i have is this so far

<?php

$todays_date = getdate();
$linkoftheday = array( 1 <= '<a href=\"http://nitrofire.net/forum\">');
?>

then in a css layer i have this

<?PHP


if ($linkoftheday==$todays_date)
echo $linkoftheday;
else {
echo 'fail';
}


?>


i know for a fact iam missing a bunch of stuff but i am stuck on finding more information on this. anyhelp would be greatly appreciated.
thanks
KillerWolf
Link to comment
Share on other sites

nope! great thing bout arrays

$array[]='';
is exactly the same as
$array = array('');

are you doing this for day of the week? month? or year... because php date function makes life sooo easy like that

week = date(N); <-- 1-7
month = date(j); <-- 1-31
year = date(z); <-- 0-365

[code]
<?
$linkoftheday[1] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[2] = '<a href="http://nitrofire.net/forum">';
ect...

echo $linkoftheday[date(z)];
?>
[/code]
Link to comment
Share on other sites

[quote author=taith link=topic=115949.msg472276#msg472276 date=1164227038]
nope! great thing bout arrays

$array[]='';
is exactly the same as
$array = array('');

are you doing this for day of the week? month? or year... because php date function makes life sooo easy like that

week = date(N); <-- 1-7
month = date(j); <-- 1-31
year = date(z); <-- 0-365

[code]
<?
$linkoftheday[1] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[2] = '<a href="http://nitrofire.net/forum">';
ect...

echo $linkoftheday[date(z)];
?>
[/code]
[/quote]

ya but with the array i thought it had to be
$linkoftheday[2] = array ('<a href="http://nitrofire.net/forum">');
Link to comment
Share on other sites

nope....

[code]
<?
$linkoftheday[0] = '<a href="http://nitrofire.net/forum"></a>';
...
$linkoftheday[365] = '<a href="http://nitrofire.net/forum"></a>';

echo $linkoftheday[date(z)];
?>
[/code]

every different day will give you a new link... considering that $linkoftheday[#] is set... try it... it'll work :-)
Link to comment
Share on other sites

i must be doing somthing wrong heres my code, iam assuming it has to due with the $linkoftheday not being set like you said, but how do i set that to work with the date function. iam more familure with Java.



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Modders Back Door</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
<!--
@import url("style2.css");
-->
</style>
</head>

<body>

<?php

$linkoftheday[0] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[1] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[2] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[3] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[4] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[5] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[6] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[7] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[8] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[9] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[10] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[11] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[12] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[13] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[14] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[15] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[16] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[17] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[18] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[19] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[20] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[21] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[22] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[23] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[24] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[25] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[26] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[27] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[28] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[29] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[30] = '<a href="http://nitrofire.net/forum">';
$linkoftheday[31] = '<a href="http://nitrofire.net/forum">';

?>



<ul>
        <li><a href="index.htm">Home</a></li>
<li><a href="linuxmods.php">Linux modds</a></li>
<li><a href="windows.php">Window modds</a></li>
<li><a href="contact.php">Contact Us</a></li>
</ul>

<!--ULR of the day -->
<div id="ULRDAY">

</div>



<div id="banner"><img src="photos/banner.jpg"></img>
</div>

<div id="Contentindex"><p class="headermain">Welcome to the Modders backdoor</p>
<p class="modpagefontcolor"> I created this site because of my love of computers and modding them. i like to take something and make it even better then it was. With in this site i will be posting a lot of my modds that i have done.  later i will even be making a forum for we all can post our updates and others work on modding.  If you wish to have your project on this site please go to the contact page for further information.
<br><br>KillerWolf
<br>
<br>
<br>
<img src="photos/secondheader.jpg"></a>



<p class="Contentindex">

<p class="modpagefontcolor">Currently on the site, we have Pencutise a case modd done by running Fedor 5 dis. of Linux.</a>

<div id="linuxmainpage">

<br>
<br>
<p class="linuxholder"><img src="photos/linuxpic2a.jpg"></a></p>

</div>

<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>

<!--<img src="photos/blank_header.jpg"></a>-->



<br>
<br>
</p>
</p>
<?

echo $linkoftheday['date(z)'];

?>
</div>


</body>
</html>

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.