PHP
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives Mailing Lists PHP

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old June 16th, 2008, 07:31 AM
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
question about the week's data read and show

Dears,

Here is my question:

I am write a project manage system.

Now I need to echo one weekˇ¦s data and send to html show.

Any one got a good idea or codes?

My code has some issues about the loop function. Could you help me check or give me some suggestion?

The show item like this:



This week is 25.th week of 2008

[Last Week]06/09/15// can be link and show the different weekˇ¦s data

[This Week]06/16/22

[Next Week]06/23/29

Found 2 records in 23ˇ¦Th week.



NAME\DAY 06/09 Monday 06/10 Tuesday 06/11 Wednesday 06/12 Thursday 06/13 Friday 06/14 Saturday 06/15 Sunday

Cathy 00 08361-sb 02 03 04 05 06

James 10 08362-sb 12 13 08362-sb 15 16

Connie 20 21 08740-sa 23 24 25 26

Ken 30 31 08741-sb 33 34 08741-sb 36



My code here (But it seems that some issues on show)

<?php

//Link to the

$link = mysql_connect('localhost', 'evel', '000000')//link the database

or die('Could not connect: ' . mysql_error());

mysql_select_db('evel') or die('Could not select database');

//show the week

$weeknumber=date(W);

$yearnumber=date(Y);

$tt=week_limits($weeknumber,$yearnumber);

$begin=date("m/d l",1212973261);

$end=date("m/d l", 1213491661);

echo "This week is $weeknumber th week of $yearnumber<br>";

echo "Date from $begin($tt[0]) to $end($tt[1])<br>";

//



//show the weekdate

$lowEnd=date("w");

$lowEnd=-$lowEnd;

$highEnd=$lowEnd +7;

$weekday=0;

$weektr.= "<link href=\"require/style.css\" rel=\"stylesheet\" type=\"text/css\">\n";

$weektr.= "<table width=\"118\" bgcolor=\"#FFFFFF\" align=center>\n";

$weektr.= "<tr>\n";

$weektr.= "<TD class=\"Content\"><FNT CLR=BLUE><B>NAME\DAY</B></FNT></TD>";

for ($i=$lowEnd+1;$i<=$highEnd;$i++)

{

$WeekDate[$weekday]=date("m/d l",mktime(0, 0, 0, date("m") , date("d")+$i, date("Y")));

$datename[$weekday]=date("N",mktime(0, 0, 0, date("m") , date("d")+$i, date("Y")));



$weektr.= "<TD nowrap align=center bgcolor=\"F1F1F1\">";

$weektr.= "$WeekDate[$weekday]";

$weektr.= "</TD>\n";

}

// of

// the data

$result = mysql_query("select PNB,Name,Time from report where Time>='1212138371' AND Time<='1212886861'");//weelresult one week time area test

$num=mysql_num_rows($result);

// echo $num;//show the record number,control the table

if($num)

{

echo "Found $num records<br>";

$weektr.= "<tr>\n";

// while($myrow=mysql_fetch_array($result,MYSQL_NUM))

// {

// $weekdaynumber=date("N",$myrow[2]);

for($x = 0;$x < $num;$x++)//create the data array,for the search resule number

{

$weekdaynumber=date("N",$myrow[2]);

for($y = 0;$y < 7;$y++)//loop for tr

{

for($i=0;$i<8;$i++)

{

if($weekdaynumber==$y)//get the relate week date data

{

$data[$x][$y] =$myrow[0];

}

else

$data[$x][$y] ="$x$y";

}

$mat[$x][$y] = "$x,$y";

}



}



//echo $weekdaynumber;



while ($x= mysql_fetch_row($result))//one by one show the data record

{ $x=0;

// for($x = 0;$x <= mysql_fetch_row($result);$x++){

// for($x = 0;$x < count($data[$x]);$x++)//output the data,as the dataarray number is

// {

for($y = 0;$y <7;$y++)

{

if($y==0)//devide the cell to name and the week date and project cell

{

$weektr.="<td align=\"center\">$myrow[1]</td>";

$weektr.="<td align=\"center\">".$data[$x][$y]."</td>";

}

else

$weektr.="<td align=\"center\">".$data[$x][$y]."</td>";

}

$x++;

$weektr.= "</tr>\n";

// }

// }

}

}

else

echo "Found 0 records";

$weektr.="</table>\n";

print $weektr;

// of



// the week time area(seconds)



function week_limits($weekNumber, $year)

{

// begin datetime

$time = mktime(1, 1, 1, 1, 1, $year);

// Aassuring that $weekNumber is number

$weekNumber--;

// If first week of year starts not from monday,

//date() will return "not correct" result (in this case first week is 0)

if (date('w', $time) == 1)

$weekNumber++;

$start_time = false;

$end_time = false;

for ($day = 1; $day <= 380; $day++)

{

if (date('W', $time) == $weekNumber && !$start_time)

$start_time = $time;

if (date('W', $time - 24*60*60) == $weekNumber && !$end_time && date('W', $time) != $weekNumber)

$end_time = $time - 24*60*60;

if ($start_time && $end_time)

break;

$time += 24*60*60;

}

return array($start_time, $end_time);

}

// of week_limits()

?>







RegardsˇI

Evel#0616

Reply With Quote
Reply

Viewing: Web Development Archives Mailing Lists PHP > question about the week's data read and show


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT