Jump to content

Hooch

Members
  • Posts

    452
  • Joined

  • Last visited

About Hooch

  • Birthday 01/01/1967

Contact Methods

  • Website URL
    http://zentyx.com
  • ICQ
    0

Profile Information

  • Location
    Ontario, Canada

Hooch's Achievements

Member

Member (2/7)

0

Reputation

  1. After trying Hadien's code for a while I'm finding it as difficult to get what I want. If someone can have a look at the original code and question for help that would be terriffic. Thank you.
  2. Hi Hadien, thanks for taking the time to help me out. It's definitely got some errors, but I will try to figure it out.
  3. Hello all. I am trying to change this old script up a bit and need some help to get it 100% correct. I'm trying to create a weekly list of 3 people and their job lineup for each of those 3 weeks.Example:Week1:Job1:LesJob2:MikeJob3:DanWeek2:Job1:DanJob2:LesJob3:MikeWeek3:Job1:MikeJob2:DanJob3:LesThen repeat the job cycle from week 1 for eternity.If you check out my results so far at LINKY you can see it is simply repeating week#3 instead of starting over as week 1.Here is my code so far: <?PHP $var1 = 'Les'; $var2 = 'Dan'; $var3 = 'Mike'; $dayName = array(1 => "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); $monthName = array(1 => "January","February","March","April","May","June","July","August","September","October","November","December"); $monthDays = array(1 => 31,28,31,30,31,30,31,31,30,31,30,31); $row1 = array($var1,$var1,$var1,$var1,$var1,$var1,$var1,$var2,$var2,$var2,$var2,$var2,$var2,$var2,$var3,$var3,$var3,$var3,$var3,$var3,$var3); $row2 = array($var2,$var2,$var2,$var2,$var2,$var2,$var2,$var3,$var3,$var3,$var3,$var3,$var3,$var3,$var1,$var1,$var1,$var1,$var1,$var1,$var1); $row3 = array($var3,$var3,$var3,$var3,$var3,$var3,$var3,$var1,$var1,$var1,$var1,$var1,$var1,$var1,$var2,$var2,$var2,$var2,$var2,$var2,$var2); $now = time(); $nowd = date('j', $now); $nowm = date('F', $now); $nowy = date('Y', $now); $startdate = date(mktime(0,0,1,10,6,2013)); //Jan 1 2001 00:00:01 $getMonth = $_POST['month']; if($getMonth == '') $getMonth = date('n', $now); $getYear = $_POST['year']; if($getYear == '') $getYear = date('Y', $now); //$getMonth = $_POST['month']; if($getMonth == 0) { $getMonth = 12; $getYear = ($getYear - 1); } elseif($getMonth == 13) { $getMonth = 1; $getYear = ($getYear + 1); } else { $getYear = $getYear; } // if this year is divisable by 4 or 100, and is divisible by 400... then change last day of feb to 29. // if($getMonth == 2) { if (($getYear%4==0)||($getYear%100==0)) {$monthDays[1]=29;} if ($getYear%400==0) {$monthDays[1]=29;} } $firstDay = date(mktime(0,0,0,$getMonth,1,$getYear)); //Jan 1 2001 00:00:01 $firstDay = date('w', $firstDay);//0 through 6 (Sun - Sat) if($getMonth == 1) $buttonMonth = 'January'; if($getMonth == 2) $buttonMonth = 'February'; if($getMonth == 3) $buttonMonth = 'March'; if($getMonth == 4) $buttonMonth = 'April'; if($getMonth == 5) $buttonMonth = 'May'; if($getMonth == 6) $buttonMonth = 'June'; if($getMonth == 7) $buttonMonth = 'July'; if($getMonth == 8) $buttonMonth = 'August'; if($getMonth == 9) $buttonMonth = 'September'; if($getMonth == 10) $buttonMonth = 'October'; if($getMonth == 11) $buttonMonth = 'November'; if($getMonth == 12) $buttonMonth = 'December'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Shift Schedule</title> <link href="styleCalendar.css" rel="stylesheet" type="text/css" /> </head> <body> <?php include_once("analyticstracking.php") ?> <table width="400px" align="center" border="0" cellpadding="1" cellspacing="0"> <tr> <td align="right"> <form method="POST"> <input type="hidden" value="<?PHP echo ($getMonth);?>" name="month"> <input type="hidden" value="<?PHP echo ($getYear-1);?>" name="year"> <input type="submit" value="<<Year" name="submit" class="button-alt" /> </form> </td> <td align="left"> <form method="POST"> <input type="hidden" value="<?PHP echo ($getMonth-1);?>" name="month"> <input type="hidden" value="<?PHP echo ($getYear);?>" name="year"> <input type="submit" value="<<Month" name="submit" class="button-alt" /> </form> </td> <td align="center"><form method="POST" action="puller.php"><input type="submit" value=" Reset " name="submit" class="button-alt" /></form></td> <td align="right"> <form method="POST"> <input type="hidden" value="<?PHP echo ($getMonth+1);?>" name="month"> <input type="hidden" value="<?PHP echo ($getYear);?>" name="year"> <input type="submit" value="Month>>" name="submit" class="button-alt" /> </form> </td> <td align="left"> <form method="POST"> <input type="hidden" value="<?PHP echo ($getMonth);?>" name="month"> <input type="hidden" value="<?PHP echo ($getYear+1);?>" name="year"> <input type="submit" value="Year>>" name="submit" class="button-alt" /> </form> </td> </tr> <tr> <td colspan="5" align="center"><H1><?PHP echo $buttonMonth;?> <?PHP echo $getYear;?></H1></td> </tr> </table> <?PHP echo '<table align="center" border="0" cellpadding="0" cellspacing="0" class="tableOutterBorder">'; echo '<tr>'; for($i = 1; $i < 8; $i++) echo '<td width="120" align="center" class="weekDayHeaderCells">' . substr($dayName[$i], 0, 3) . '</td>'; echo '</tr>'; echo '<tr>'; $dayCount = 1; for ($ii = 0; $ii < $firstDay; $ii++) $dayCount = $dayCount + 1; if($ii >=1) echo '<td colspan="'.$ii.'" width="'.($ii*120).'" height="90" align="left" class="emptyCells"></td>';//Empty if($monthDays[1] == 29) $daysInMonth = 29; else $daysInMonth = $monthDays[$getMonth]; for ($i = 1; $i <= $daysInMonth; $i++) { $fDate = mktime(0,0,0,$getMonth,$i,$getYear);//Hr Mn Sec Mn Dy Yr $diffdate = round(($fDate - $startdate)/86400); $remainder = $diffdate%28; $showRow1 = $row1[$remainder]; $showRow2 = $row2[$remainder]; $showRow3 = $row3[$remainder]; //Highlight today if this month is selected if($getYear == $nowy && $i == $nowd && $buttonMonth == $nowm)$live = "Live"; if($showRow1 == $var1){ $class = "dayCellsE1" . $live; $weekSet = 1; $showJobs = '<br />Puller:'.$var1.'<br>Ground:'.$var2.'<br>Loco:'.$var3; }elseif($showRow1 == $var2){ $class = "dayCellsE2" . $live; $weekSet = 2; $showJobs = '<br />Puller:'.$var2.'<br>Ground:'.$var3.'<br>Loco:'.$var1; }else{ $class = "dayCellsE3" . $live; $weekSet = 3; $showJobs = '<br />Puller:'.$var3.'<br>Ground:'.$var1.'<br>Loco:'.$var2; } echo '<td width="120" height="90" valign="top" align="center" class="'.$class.'">'; echo '<span class="text_16_white">'.$i.'</span>'.$showJobs; echo '</td>'; $live = ''; if (($i+$firstDay)%7==0&&($dayCount<$daysInMonth+1)) echo '</tr><tr>'; } $totCells = $firstDay + $daysInMonth; for ($i = 0; $i < ($totCells > 28 ? ($totCells > 35 ? 42 : 35) : 28) - $totCells; $i++) echo ''; if($i >=1) echo '<td colspan="'.$i.'" width="'.($i*120).'" height="90" align="left" class="emptyCells"></td>';//Empty echo '</tr>'; echo '</table>'; ?> <br /> <center><a href="../" class="button-alt">ZENTYX</a></center> </body> </html> Any help is greatly appreciated.
  4. Ooops..I got to this post via my panel and forgot it started in javascript. Sorry for posting this PHP problem here. I removed the above post and added a new one to PHP
  5. Thanks for the info guys.Using javascript is not something I do often so I decided to convert it all to PHP. I appreciate you taking the time to help me. If anyone wants the code I will post it. Oh..if you want to see what I was going for look here...This is a 12hr shift schedule my workplace has. Now we cansee what we are working months/years in advance. Againthank you. Hooch
  6. Thanks Guy.But this gives me more errors. To show you how I implemented your code look below <script LANGUAGE="JavaScript"><!-- var dayName=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); var monthName=newArray("January","February","March","April","May","June","July","August","September","October","November","December"); var monthDays=new Array(31,28,31,30,31,30,31,31,30,31,30,31); var ondays=newArray("D","D","A","A","B","B","B","C","C","D","D","A","A","A","B","B","C","C","D","D","D","A","A","B","B","C","C","C"); var onnights=newArray("B","B","C","C","D","D","D","A","A","B","B","C","C","C","D","D","A","A","B","B","B","C","C","D","D","A","A","A"); var now=new Date(); var nowd=now.getDate(); var nowm=now.getMonth(); var nowy=now.getYear(); var startdate=new Date("Jan 1 2001 00:00:01"); function showCalendar(day,month,year) { // if this year is divisable by 4 or 100, and is divisible by 400... then change last day of feb to 29. // if ((year%4==0)||(year%100==0)) {monthDays[1]=29;} if (year%400==0) {monthDays[1]=29;} var firstDay=new Date(year,month,1).getDay() var calStr="<br><span id=instruction>Instruction<br></span id=instruction>" calStr+="<div class=headerRow>" calStr+="<span class=headerLeft><InPut type = button value = 'Last Month' onClick='nowm--; if (nowm<0) { nowy--;nowm=11; } showCalendar(nowd,nowm,nowy)'></span>" calStr+="<span class=headerRight><InPut type = button value = 'Next Month'onClick='nowm++; if (nowm>11) { nowy++;nowm=0; } showCalendar(nowd,nowm,nowy)'></span>" calStr+="<span class=headerCenter><font size=2>12 Hour Shift Schedule</font><br>"+monthName[month].toUpperCase()+","+year+"</span>" calStr+="</div class=headerRow><div class=headerDayRow>" for (var i=0;i<dayName.length;i++) calStr+="<span class=headerDays>"+dayName[i].substring(0,3)+"</span>" var dayCount=1 calStr+="</div class=headerDayRow><div class=dayRow>" for (var i=0;i<firstDay;i++) calStr+="<span class=emptyDaysTop> </span>" for (var i=0;i<monthDays[month];i++) {if (ondays == 'A' || ondays == 'C'){ calStr+="<span class=ACDays><span class=daynumber>"+dayCount++} else if (ondays == 'B' || ondays == 'D'){ calStr+="<span class=BDDays><span class=daynumber>"+dayCount++} var fDate = new Date(monthName[month]+" "+dayCount+" "+nowy+" 00:00:01") var diffdate = (fDate - startdate)/86400000 -1 var diffdate = Math.round(diffdate) var remainder=diffdate%28 var days=ondays[remainder] var nights=onnights[remainder] calStr+="</span><br><b>Days= " calStr+=days calStr+="<br>Nights= " calStr+=nights+"</b></span>" if ((i+firstDay+1)%7==0&&(dayCount<monthDays[month]+1)) calStr+="</div><div class=dayRow>" } var totCells=firstDay+monthDays[month] for (var i=0;i<(totCells>28?(totCells>35?42:35):28)-totCells;i++) calStr+="<span class=emptyDaysBottom> </span>" calStr+="</div>" //define what html to put in the span tag // calendar.innerHTML=calStr } //--></SCRIPT></head><body background="" bgcolor="#CCCCCC" text="#000000" link="#996600" vlink="#666666" alink="#336600"><center><SPAN ID=calendar><script> showCalendar(nowd,nowm,nowy)</SCRIPT></SPAN></center></body></html> This my show you what I am trying to do.Just an FYI this code (well the 1st code posted) only works in IE not FF Hooch
  7. Hi all.I came across a script that is exactly what I need, unfortunately it's mostly JS.I could work things out if it were PHP but I need some help here. Here is the code.. <html> <head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><title>Shift Schedule</title> </head><body background="" bgcolor="#CCCCCC" text="#000000" link="#996600" vlink="#666666" alink="#336600"><script LANGUAGE="JavaScript"><!-- var dayName=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); var monthName=new Array("January","February","March","April","May","June","July","August","September","October","November","December"); var monthDays=new Array(31,28,31,30,31,30,31,31,30,31,30,31); var ondays=new Array("D","D","A","A","B","B","B","C","C","D","D","A","A","A","B","B","C","C","D","D","D","A","A","B","B","C","C","C"); var onnights=new Array("B","B","C","C","D","D","D","A","A","B","B","C","C","C","D","D","A","A","B","B","B","C","C","D","D","A","A","A"); var now=new Date(); var nowd=now.getDate(); var nowm=now.getMonth(); var nowy=now.getYear(); var startdate=new Date("Jan 1 2001 00:00:01"); function showCalendar(day,month,year) { // if this year is divisable by 4 or 100, and is divisible by 400... then change last day of feb to 29. // if ((year%4==0)||(year%100==0)) {monthDays[1]=29;} if (year%400==0) {monthDays[1]=29;} var firstDay=new Date(year,month,1).getDay() var calStr="<br><span id=instruction>Instruction<br></span id=instruction>" calStr+="<div class=headerRow>" calStr+="<span class=headerLeft><InPut type = button value = 'Last Month' onClick='nowm--; if (nowm<0) { nowy--; nowm=11; } showCalendar(nowd,nowm,nowy)'></span>" calStr+="<span class=headerRight><InPut type = button value = 'Next Month'onClick='nowm++; if (nowm>11) { nowy++; nowm=0; } showCalendar(nowd,nowm,nowy)'></span>" calStr+="<span class=headerCenter><font size=2>12 Hour Shift Schedule</font><br>"+monthName[month].toUpperCase()+", "+year+"</span>" calStr+="</div class=headerRow><div class=headerDayRow>" for (var i=0;i<dayName.length;i++) calStr+="<span class=headerDays>"+dayName[i].substring(0,3)+"</span>" var dayCount=1 calStr+="</div class=headerDayRow><div class=dayRow>" for (var i=0;i<firstDay;i++) calStr+="<span class=emptyDaysTop> </span>" for (var i=0;i<monthDays[month];i++) { calStr+="<span class=ACDays><span class=daynumber>"+dayCount++ var fDate = new Date(monthName[month]+" "+dayCount+" "+nowy+" 00:00:01") var diffdate = (fDate - startdate)/86400000 -1 var diffdate = Math.round(diffdate) var remainder=diffdate%28 var days=ondays[remainder] var nights=onnights[remainder] calStr+="</span><br><b>Days= " calStr+=days calStr+="<br>Nights= " calStr+=nights+"</b></span>" if ((i+firstDay+1)%7==0&&(dayCount<monthDays[month]+1)) calStr+="</div><div class=dayRow>" } var totCells=firstDay+monthDays[month] for (var i=0;i<(totCells>28?(totCells>35?42:35):28)-totCells;i++) calStr+="<span class=emptyDaysBottom> </span>" calStr+="</div>" //define what html to put in the span tag // calendar.innerHTML=calStr } //--></SCRIPT><center><SPAN ID=calendar><script> showCalendar(nowd,nowm,nowy)</SCRIPT></SPAN></center></body></html> Basically I need the following line calStr+="<span class=ACDays><span class=daynumber>"+dayCount++ to switch from it to this calStr+="<span class=BDDays><span class=daynumber>"+dayCount++ whenever the variable ondays is either A or C show the switch 1. When variable ondays is either B or D show switch 2. I tried many different ways with my knowledge of PHP but nothing works. Thank you for your time
  8. Gotcha! Thank you.
  9. Thanks reportingsjr, but I was wanting to trythis operation as is. It's a neat way to save some code. FYI if $a and $b do equal they will print out.. the query is equal1
  10. Hello all. I am trying out something new, and low and beholdI have a problem. The code below echo's out a "1" (without quotes)at the end of my text. <?PHP$a = "555";$b = "5555";$string = ($a == $b) ? include 'equal.php' : include 'not_equal.php';echo $string;?> equal.php <?PHPecho "the query is equal";?> not_equal.php <?PHPecho "the query is not equal";?> The above code prints out... the query is not equal1 Why is this? Thank youHooch
  11. ok great thanks man. Maybe I will add some text to the DB wheneverthis happens. It would be nice to know how many direct linksfrom the address bar are happening. More infois better. Well explained as usual, thank you Guy.
  12. Hello, I have yet another question. I am making a referrals page. It works almost to a tee. But whenI link to my page fom my browser it recordsnothing. The command for recording a referral from anactual web page is $url = $_SERVER['HTTP_REFERER']; Is there a similar "Predefined Variable" for a referralwhen one comes from the address bar? Right now I have a temporary fix that does nothingif $url = NULL. I was wondering if it's possible to record the userscomputer name?Thanks..Hooch
  13. Hooch

    using more sessions

    Here's how I ended up getting it to work.Thank you justsomeguy and vijay. <?phpsession_start();include 'includes/online.php';include 'includes/db.php';include 'includes/header.php';if (!($_SESSION['logged'] == 1)) { // #1 not logged inif (!$_POST['login']) { // #2 no post yet?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><link href="includes/style.css" rel="stylesheet" type="text/css" /></head><body><table width="100" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="35"> </td> </tr></table><table border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#999999"><form method="POST"> <tr> <td align=right> Username: <input name="username" type="text" class="txtbox" size="15" maxlength="25"></td> </tr> <tr> <td align="right"> Password: <input name="password" type="password" class="txtbox" size="15" maxlength="25"></td></tr><tr> <td align="center"> <input name="login" type="submit" class="txtbox" value="login"></td></tr> <tr> <td align="center"><a href="forgot_pass.php" target"_self" class="tia">Forgot Password</a><br> <a href="index.php" class="tour-footer">Home</a></td> </tr></form></table><?PHP } // #2 (end) just had a postif ($_POST['login']) { // #3 just had a postinclude 'includes/clean.php'; $username = clean($_POST['username']);$password = clean($_POST['password']);$query = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); $r = mysql_fetch_array($query); $password2 = sha1($password);$password2 = sha1(substr($password2, 0, 20) . substr($r['salt'], 0, 20) . substr($password2, 19, 20) . substr($r['salt'], 19, 20)); if ($r['username'] == $username && $r['password'] == $password2){ // #4 check for username and pw $_SESSION['logged'] = 1; $_SESSION['username'] = $r['username']; $_SESSION['level'] = $r['level']; $_SESSION['accept'] = 0;} // #4 (end) check for username & pw is okelse{ // #5 username & pw is not ok $_SESSION['logged'] = 0; echo "<center><br><br><span class=\"black-medium\">Incorrect username or password!</span><br><br>"; echo "<a href=\"login.php\" target\"_self\" class=\"members\">Back</a><br><br><br>"; } // #5 (end) since username and pw are not ok, try again} // #3 (end) had a post and everything is ok} // #1 (end) user is logged inelse{session_write_close();}if ($_SESSION['logged'] == 1) {echo "<link href=\"includes/style.css\" rel=\"stylesheet\" type=\"text/css\" />";echo "<meta http-equiv=\"Refresh\" content=\"0; URL=profile.php\"/>";}else{}?></body></html>
  14. Hooch

    using more sessions

    The best spot I could find to put your code was in the same placethe old refresh was.It does not send me to profile.php. <?phpsession_start();include 'includes/online.php';include 'includes/db.php';include 'includes/header.php';if (!$_SESSION['logged'] == 1) { // #1 not logged inif (!$_POST['login']) { // #2 no post yet?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><link href="includes/style.css" rel="stylesheet" type="text/css" /></head><body><table width="100" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="35"> </td> </tr></table><table border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#999999"><form method="POST"> <tr> <td align=right> Username: <input name="username" type="text" class="txtbox" size="15" maxlength="25"></td> </tr> <tr> <td align="right"> Password: <input name="password" type="password" class="txtbox" size="15" maxlength="25"></td></tr><tr> <td align="center"> <input name="login" type="submit" class="txtbox" value="Login"></td></tr> <tr> <td align="center"><a href="forgot_pass.php" target"_self" class="tia">Forgot Password</a><br> <a href="index.php" class="tour-footer">Home</a></td> </tr></form></table><?PHP } // #2 (end) just had a postif ($_POST['login']) { // #3 just had a postinclude 'includes/clean.php'; $username = clean($_POST['username']);$password = clean($_POST['password']);$query = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); $r = mysql_fetch_array($query); $password2 = sha1($password);$password2 = sha1(substr($password2, 0, 20) . substr($r['salt'], 0, 20) . substr($password2, 19, 20) . substr($r['salt'], 19, 20)); if ($r['username'] == $username && $r['password'] == $password2){ // #4 check for username and pw $_SESSION['logged'] = 1; $_SESSION['username'] = $r['username']; $_SESSION['level'] = $r['level']; $_SESSION['accept'] = 0;} // #4 (end) check for username & pw is okelse{ // #5 username & pw is not ok $_SESSION['logged'] = 0; echo "<center><br><br><span class=\"black-medium\">Incorrect username or password!</span><br><br>"; echo "<a href=\"login.php\" target\"_self\" class=\"members\">Back</a><br><br><br>"; } // #5 (end) since username and pw are not ok, try again} // #3 (end) had a post and everything is ok} // #1 (end) user is logged inelse{?><html><head><link href="includes/style.css" rel="stylesheet" type="text/css" /><meta http-equiv="Refresh" content="0;url=profile.php" /></head><body><a href="profile.php">Redirect</a></body></html><?PHP}?></body></html> The page source is as follows... </body></html> Why is that last "else" not working? Is my code completely messed up?Thank you very much for taking the time to look at my questionand helping me with another answer.Hooch
×
×
  • Create New...