Jump to content


Photo

Okay, I give up. What's the answer?


  • Please log in to reply
28 replies to this topic

#21 Moron

Moron
  • Members
  • PipPipPip
  • Advanced Member
  • 368 posts

Posted 18 August 2006 - 02:02 PM

while ($RESULT = mssql_fetch_assoc($RESULTDS))  {
if($RESULT['LYR'].".".$RESULT['Lmo'].".".$RESULT['Lda'] < "2006.7.1") continue;
echo "<tr align=center>";
    echo "<td>";
    echo $RESULT['Lmo']; 
    echo "/";
    echo $RESULT['Lda'];
    echo "/";
    echo $RESULT['LYR']; 
    echo "</td>";
  }
  echo "<td>";
  echo $RESULT['Leave Code'];
  echo "</td>";

  echo "<td>";
  $TotalGenHours = $TotalGenHours + $RESULT['Hours'];
  echo $RESULT['Hours']; 
  echo "</td>";

  echo "</tr>";
}
:)


Thanks. This doesn't error but it returns no records whatsoever.

:-[

#22 Ifa

Ifa
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts
  • LocationRauma, Finland

Posted 18 August 2006 - 02:05 PM

Is the $RESULT['LYR'] two or four numbers? ie 06 or 2006?
I'm just a guy who likes to code for fun...

#23 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 18 August 2006 - 02:08 PM

OK here is the table structure i recreated
CREATE TABLE `testtable` (
  `Leave Code` varchar(100) NOT NULL default '',
  `Hours` varchar(100) NOT NULL default '',
  `LYR` varchar(100) NOT NULL default '',
  `Lmo` varchar(100) NOT NULL default '',
  `Lda` varchar(100) NOT NULL default '',
  `id` int(11) unsigned NOT NULL auto_increment,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

-- 
-- Dumping data for table `testtable`
-- 

INSERT INTO `testtable` VALUES ('222', '4', '2006', '01', '01', 1);
INSERT INTO `testtable` VALUES ('254', '9', '2006', '02', '02', 2);
INSERT INTO `testtable` VALUES ('254', '6', '2006', '07', '01', 3);
INSERT INTO `testtable` VALUES ('258', '5', '2006', '08', '01', 4);
INSERT INTO `testtable` VALUES ('257', '8', '2006', '09', '01', 5);

And here is the code i used
<?
$TotalGenHours = 0;
$sql = "SELECT * FROM testtable";
  $RESULTDS = mysql_query($sql) or die (mysql_error());
  while ($RESULT = mysql_fetch_assoc($RESULTDS))  {
  $day=$RESULT['LYR']."/".$RESULT['Lmo']."/".$RESULT['Lda'];
  $day_timestamp=strtotime($day);
  if ($day_timestamp >= 1151726400){

    echo "<tr align=center>";
    echo "<td>";
    echo $RESULT['Lmo'];
    echo "/";
    echo $RESULT['Lda'];
    echo "/";
    echo $RESULT['LYR'];
    echo "</td>";

    echo "<td>";
    echo $RESULT['Leave Code'];
    echo "</td>";

    echo "<td>";
    $TotalGenHours = $TotalGenHours + $RESULT['Hours'];
    echo $RESULT['Hours'];
    echo "</td>";

    echo "</tr>";
  }
}

?>

Works fine for me

Ray

#24 Moron

Moron
  • Members
  • PipPipPip
  • Advanced Member
  • 368 posts

Posted 18 August 2006 - 02:09 PM

Is the $RESULT['LYR'] two or four numbers? ie 06 or 2006?


It's four (2006).


#25 Moron

Moron
  • Members
  • PipPipPip
  • Advanced Member
  • 368 posts

Posted 18 August 2006 - 02:19 PM

Should this part be inside php tags?


CREATE TABLE `testtable` (
  `Leave Code` varchar(100) NOT NULL default '',
  `Hours` varchar(100) NOT NULL default '',
  `LYR` varchar(100) NOT NULL default '',
  `Lmo` varchar(100) NOT NULL default '',
  `Lda` varchar(100) NOT NULL default '',
  `id` int(11) unsigned NOT NULL auto_increment,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

-- 
-- Dumping data for table `testtable`
-- 

INSERT INTO `testtable` VALUES ('222', '4', '2006', '01', '01', 1);
INSERT INTO `testtable` VALUES ('254', '9', '2006', '02', '02', 2);
INSERT INTO `testtable` VALUES ('254', '6', '2006', '07', '01', 3);
INSERT INTO `testtable` VALUES ('258', '5', '2006', '08', '01', 4);
INSERT INTO `testtable` VALUES ('257', '8', '2006', '09', '01', 5);




#26 Ifa

Ifa
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts
  • LocationRauma, Finland

Posted 18 August 2006 - 02:21 PM

Why varchar(100) on the day, month and year?
I'm just a guy who likes to code for fun...

#27 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 18 August 2006 - 02:35 PM

That is just showing you what my table is structured like. Has nothing to do with the code. DO NOT INCLUDE IT ON YOUR PAGE!!

Well I keep asking how the fields are structured and I get no answer so I set them as varchar for worst case senario.

Ray

#28 Moron

Moron
  • Members
  • PipPipPip
  • Advanced Member
  • 368 posts

Posted 18 August 2006 - 02:41 PM

That is just showing you what my table is structured like. Has nothing to do with the code. DO NOT INCLUDE IT ON YOUR PAGE!!

Well I keep asking how the fields are structured and I get no answer so I set them as varchar for worst case senario.

Ray


I see. Thanks. I first tried it with only the second section and it tossed a syntax error. I'll take another crack at it.


#29 akrytus

akrytus
  • Members
  • PipPipPip
  • Advanced Member
  • 70 posts

Posted 18 August 2006 - 06:25 PM

Really that last post by craygo should work.  No problem.

Ohh sorry about the error I posted originally.

also this does not look right


Code:
$day=$RESULT['Lmo']."/".$RESULT['Lda']."/".$RESULT['Lda'];
  $day_timestamp=strtotime($day);
shouldn't it be

Code:
  $day=$RESULT['LYR']."/".$RESULT['Lmo']."/".$RESULT['Lda'];
  $day_timestamp=strtotime($day);






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users