Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php NO MYSQL webcomic question

Status
Not open for further replies.

kpdvx

Programmer
Dec 1, 2001
87
US
hi, im creating a webcomic site (with no SQL) for a few friends. i didnt think it would be much of a problem but i have run into a few difficulties. They want the comic to be updated every monday, wednesday and friday, the code i have written for that works, you guys are php programmers so i will let the code explain itself:

<?php
//PREVIOUS BUTTON ENABLE AND PREVIOUS BUTTON LINK
$prevbutt1 = &quot;<a href=\&quot;&quot;;
$prevlink = $back.$arch_day.$back1.$arch_date;
$prevbutt2 = &quot;\&quot;><img src=\&quot;decoration/last.gif\&quot; border=\&quot;0\&quot;></a></td>&quot;;

//NEXT BUTTON ENABLE AND NEXT BUTTON LINK


$date = date(mdy);
$day2 = date(d) -1;
$oddday = $day2 +1;

if (date(w) == 0)
$evenday = date(d) -2;
else
$evenday = date(d) -1;

$daynum = date(w);
$month = date(m);
$year = date(y);
$cext = &quot;.gif&quot;;
$rext = &quot;.txt&quot;;
$pext = &quot;.php&quot;;

$back = &quot;back.php?arch_day=&quot;;
$next = &quot;next.php?arch_day=&quot;;
$back1 = &quot;&arch_date=&quot;;
$next1 = &quot;&arch_date=&quot;;

$configdirec = &quot;issues/config/&quot;;
$comicdirec = &quot;issues/comics/&quot;;
$natedirec = &quot;issues/rants/nate/&quot;;
$joshdirec = &quot;issues/rants/josh/&quot;;
$oddcomic = $comicdirec.$month.$oddday.$year.$cext;
$evencomic = $comicdirec.$month.$evenday.$year.$cext;
$naterant = $natedirec.$date.$rext;
$joshrant = $joshdirec.$date.$rext;
$joshdirec = &quot;issues/rants/josh/&quot;;
$oddrantjosh = $joshdirec.$month.$oddday.$year.$rext;
$evenrantjosh = $joshdirec.$month.$evenday.$year.$rext;
$oddrantnate = $natedirec.$month.$oddday.$year.$rext;
$evenrantnate = $natedirec.$month.$evenday.$year.$rext;
$prevlink = $back.$daynum.$back1.$oddday;
$nextlink = $next.$daynum.$next1.$oddday;


/*
This function takes day nubmer ($intnumber)
and then updates the comic depending on whether
it is odd or even
*/
$intNumber = date(w);
{
if ($intNumber % 2 == 0 && $intNumber < 7)
{
//The day is even
$comic = $evencomic;
$joshrant = $evenrantjosh;
$naterant = $evenrantnate;
}
else
{
//The day is odd
$comic = $oddcomic;
$joshrant = $oddrantjosh;
$naterant = $oddrantnate;
}
}

?>

you can see how that works.

here is my problem(s).
they want a back, and a next button, to take them to the past date, when they are on the last date that there is (first comic in other words) the back link will be disabled (and the gif that linked to it). Then next code takes you forward, when it gets to todays date, the next button is disabled. here is the code i have for the back links, the next link is pretty much the same, so i wont post it:

<?
//set dates
$month = date(m);
$year = date(y);
$curr_date = date(d);

$date_back = $arch_date;


if ($arch_day == 1)
$arch_date = $arch_date -2;
else if ($arch_day == 2)
$arch_date = $arch_date -2;

else if ($arch_day == 3)
$arch_date = $arch_date -2;

else if ($arch_day == 4)
$arch_date = $arch_date -2;

else if ($arch_day == 5)
$arch_date = $arch_date -2;

else if ($arch_day == 6)
$arch_date = $arch_date -2;

else if ($arch_day == 0)
$arch_date = $arch_date -4;



//format the date month-day-year
$archive = $month.$arch_date.$year;


//set directories
$cext = &quot;.gif&quot;;
$rext = &quot;.txt&quot;;
$pext = &quot;.php&quot;;
$comicdirec = &quot;issues/comics/&quot;;
$natedirec = &quot;issues/rants/nate/&quot;;
$joshdirec = &quot;issues/rants/josh/&quot;;
$comic = $comicdirec.$archive.$cext;
$naterant = $natedirec.$archive.$rext;
$joshrant = $joshdirec.$archive.$rext;

$back = &quot;back.php?arch_day=&quot;;
$next = &quot;next.php?arch_day=&quot;;
$back1 = &quot;&arch_date=&quot;;
$next1 = &quot;&arch_date=&quot;;

$arch_day = $arch_day -1;

if ($arch_day < 0)
$arch_day = &quot;6&quot;;
else
$arch_day = $arch_day;

//PREVIOUS BUTTON ENABLE AND PREVIOUS BUTTON LINK
$prevbutt1 = &quot;<a href=\&quot;&quot;;
$prevlink = $back.$arch_day.$back1.$arch_date;
$prevbutt2 = &quot;\&quot;><img src=\&quot;decoration/last.gif\&quot; border=\&quot;0\&quot;></a></td>&quot;;

//NEXT BUTTON ENABLE AND NEXT BUTTON LINK
$nextbutt1 = &quot;<a href=\&quot;&quot;;
$nextlink = $next.$arch_day.$next1.$arch_date;
$nextbutt2 = &quot;\&quot;><img src=\&quot;decoration/next.gif\&quot; border=\&quot;0\&quot;></a></td>&quot;;


//now we include the template so we can show da comix
echo $arch_date;
echo &quot;<br>&quot;;
echo $arch_day;
//INSERT TEMPLATES
include ('templates/header.php');
echo &quot;<br>&quot;;

//CURRENT COMIC TO BE DISPLAYED
include ('templates/main.php');

echo &quot;<br>&quot;;
include ('navigation/botnavi.php');
echo &quot;<br>&quot;;

//CURRENT RANTS TO BE DISPLAYED

include ('templates/rants.php');


echo &quot;<br>&quot;;
include ('templates/footer.php');

$archive = &quot;&quot;;

?>

problem is, that doesnt work, it takes me back too far one day sometimes (almost as if when php wants to work, it will) it has do do with the current day, but if it is subtracted by 1 everytime, i cant se that there would be any problems.

please consider helping me out, thanks,

-kpdvx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top