Location: PHPKode > scripts > The First Year Script > the-first-year-script/firstyear.php
<?

$list = file ("../firstyear/customize.csv");
$numberc = '0';
$lines = count($list);

          while ($numberc < $lines)
          {
               $item = "$list[$numberc]";
               $pieces = explode(",", $item);

               // example breakup of fields
               $name = "$pieces[0]";
	       $birthday = "$pieces[1] $pieces[2], $pieces[3]";
	       $sex = "$pieces[4]";

               // do something with the variables....
               $numberc ++;
          }

$list = file ("../firstyear/pictures.csv");
$numberp = '0';
$lines = count($list);

          while ($numberp < $lines)
          {
               $item = "$list[$numberp]";
               $pieces = explode(",", $item);

               // example breakup of fields
               $pic = "$pieces[0]";
               $tn = "$pieces[1]";
               $picdate = "$pieces[2]";

               // do something with the variables....
               $numberp ++;
          }

$list = file ("../firstyear/milestones.csv");
$numberm = '0';
$lines = count($list);

          while ($numberm < $lines)
          {
               $item = "$list[$numberm]";
               $pieces = explode(",", $item);

               // example breakup of fields
               $mile = "$pieces[0]";
               $miledate = "$pieces[1]";

               // do something with the variables....
               $numberm ++;
          }

$now = strtotime ("now");
$then = strtotime ("$birthday");
$difference = $now - $then ;
$days = intval($difference/86400);
$num = $difference/86400;
$num1 = $num/365;
$years = intval($num1);
$temp = $difference/86400 - $years*365;
$num2 = $temp/30;
$months = intval($num2);
$temp = $difference/86400 - ($years*365) - ($months*30);
$num3 = $temp/7;
$weeks = intval($num3);
$num3a = $difference/86400 - ($years*365) - ($months*30) - ($weeks*7);
$days2 = intval($num3a);

if($sex == "boy")
	{
		$he = "He";
		$is = "is";
		$was = "was";
	}
elseif($sex == "girl")
	{
		$he = "She";
		$is = "is";
		$was = "was";
	}
elseif($sex == "twins")
	{
		$he = "They";
		$is = "are";
		$was = "were";
	}
else
	{}

if ($years == "1")
	{
		$year = "$years year";
	}
else
	{
		$year = "$years years";
	}

if ($months == "1")
	{
		$month = "$months month";
	}
else
	{
		$month = "$months months";
	}

if ($weeks == "1")
	{
		$week = "$weeks week";
	}
else
	{
		$week = "$weeks weeks";
	}

if ($days == "1")
	{
		$day = "$days day";
	}
else
	{
		$day = "$days days";
	}

if ($days2 == "1")
	{
		$day2 = "$days2 day";
	}
else
	{
		$day2 = "$days2 days";
	}

if ($days > "365")
	{
		print"$name $was born on $birthday.  $he $is $year, $month and $week old.<br><br>";
	}
elseif ($days > "30")
	{
		print"$name $was born on $birthday.  $he $is $month, $week and $day2 old.<br><br>";
	}
elseif ($days > "7")
	{
		print"$name $was born on $birthday.  $he $is $week and $day2 old.<br><br>";
	}
else
	{
		print"$name $was born on $birthday.  $he $is $day old.<br><br>";
	}

if ($pic == "VOID")
	{
		print"<div align=\"center\"><img src=\"../firstyear/baby.gif\" border=\"0\"></div>";
	}
else
	{
		print"<center><a href=\"$pic\" target=\"_blank\"><img src=\"$tn\" border=\"0\"></a><br>$picdate</center>";
	}

print"<br><br>$mile on $miledate.";

print"<br><br>Get your own <a href=\"http://usr-bin-mom.com/journal.php?id=474\" target=\"_blank\">first year script</a>!";

?>
Return current item: The First Year Script