Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,191,244 members, 7,943,470 topics. Date: Sunday, 08 September 2024 at 04:23 PM

G99ma's Posts

Nairaland Forum / G99ma's Profile / G99ma's Posts

(1) (of 1 pages)

Programming / Re: Help Needed With Mysql/php Date Query by g99ma(f): 6:08pm On Sep 13, 2007
@xanadu
Thanks so much for your help , though I didn't do exactly what you suggested (creating a new table for weeks in the database, etc). Your if statement was exactly what I needed with a lil tweaking.

All,
Thanks for trying to help out as well , twas much appreciated.
Programming / Re: Help Needed With Mysql/php Date Query by g99ma(f): 9:28pm On Sep 12, 2007
@Fikzy

Find below my php code , sorry that it's a bit long. Also find attached a sample picture of how the report looks like. From the picture you can see that ADN for BG start and end date is Sept 13, 2007 to Oct 13 2007, thus week 42 (Oct 14 - Oct 20) should ideally be 0 (more explanation in the code below). Hope you can help me out.
Thanks
<?php
/**
* Graph
*
* This page display tool forecast report for clients
*
* @package TTS
* @author Ashley Akinpelu
*/
session_start();
header("Cache-control: private"wink;
if (!isset($_SESSION['initiated']))
{
session_regenerate_id();
$_SESSION['initiated']=true;
}
/** mysql functions */
require_once 'mysqlfunctions.php';
//getting database link
$dblink=dbconnect();
/** Site wide functions */
include "functions.php";
/** include standard header file and defines common <head> properties */
$heading="Tool Tracking System | Reports | All Tools";
$topic="Report - All Tools (Client Listing)";
include "header.php";
$admin=$_SESSION['Admin'];
$name=$_SESSION['Name'];
/** File that checks for legitimate login */
include "security.php";
$table="forecast";
$begin=$_SESSION['ccst'];//begin date
$by=substr($begin, 0, 4);//begin year
$bm=substr($begin, 5, 2);//begin month
$bd=substr($begin, 8, 2);//begin day
$end=$_SESSION['ccfh'];//end date
$lbegin=$_SESSION['cclst'];//label begin date
$lend=$_SESSION['cclfh'];//lable end date
$beginw=$_GET['bwk'];//begin week
$endw=$_GET['ewk'];//end week
//writing select query to get row count for date range
$ctsql="SELECT count(*) as ToT FROM $table WHERE start>='$begin' AND end<='$end'";
//executing the select query
$ctres=mysql_query($ctsql,$dblink);
$ctrow=mysql_fetch_array($ctres);
//if row count is zero, no data
if ($ctrow[ToT]==0)
{
echo "<script>alert('Null data was returned from the database for the date range selected. Please select a new date range.')</script>";
echo "<script>window.document.location='report.php'</script>";
}
else
{
$wks=array();
$wkval=array();
//put the week numbers for the date range in an array
for ($week=$beginw; $week<=$endw; $week++)
{
$wks[]=($week);
}
$cwks=count($wks);
if($cwks>10)
{
echo "<script>alert('Please select a new date range that do not span over more than 2 months.')</script>";
echo "<script>window.document.location='report.php'</script>";
}
else
{
for ($i=0; $i<$cwks; $i++)
{
$x=6;
//Timestamp of begin and end dates
$timestamp=mktime(1,1,1,$bm,$bd,$by);
//retrieve week for the begin and end dates
$beginDay=date("w",$timestamp);
//get first day of the begin weeks
$timestampbegin[$i]=$timestamp-(60*60*24)*$beginDay;
$timestampbeginSat[$i]=$timestampbegin[$i]+($x*24 * 60 * 60);
if ($i>0 and $i<$cwks)
{
$y=($i*$x)+$i;
$timestampbegin[$i]=$timestampbegin[$i]+($y*24 * 60 * 60);
$timestampbeginSat[$i]=$timestampbegin[$i]+($x*24 * 60 * 60);
}
$bw[$i]=date("Y-m-d",$timestampbegin[$i]);
$ew[$i]=date("Y-m-d",$timestampbeginSat[$i]);
}
//writing select query to get client that have records for the selected date range
$query="SELECT client_name, count(comp_name) as NumTtl FROM $table WHERE start>='$begin' AND end<='$end'
GROUP BY client_name ORDER BY client_name";
//executing the select query
$result=mysql_query($query,$dblink);
$topic1="$name";
?>
<link href="css/tts.css" rel="stylesheet" type="text/css">
<script type="text/javascript" language="javascript" src="javascript/js.js"></script>
</head>
<body>
<div id="container">
<div id="wcome">
<?php
echo $topic1;
?>
</div>
<div id="header">
<?php
echo $topic;
?>
</div>
<div id="date">
<?php
echo date("F j, Y"wink;
?>
</div>
<div id="center">
<form action="<?php echo $_server['php_self'];?>" method="post" name="aform">
<div class="article">
<?php
echo "<u><b>Date Range:</b> $lbegin - $lend</u><br><br>";
while($row=mysql_fetch_array($result))
{
$clnt=$row[0];
$ent=$row[1];
if ($ent==1)
{
$entf=$ent.' entry found:';
}
if ($ent>1)
{
$entf=$ent.' entries found:';
}
echo "<div class=\"entryH\">$clnt</div>";
echo "<div class=\"entry\">$entf</div>";
//for each cleint name returned get some data from the database
$sql="SELECT comp_name, tool_size, hole_size, func, start, end FROM $table WHERE client_name='$clnt' AND start>='$begin'
AND end<='$end'";
$number=0;
//executing the select query
$res=mysql_query($sql, $dblink) or die("query failed : " . mysql_error());
echo "<table class=\"tab\">
<tr class=\"colHead\">
<td>Name</td>
<td>Tool Size</td>
<td>Hole Size</td>
<td>Avail</td>";
//create td for the numbers of weeks in the date range
for ($i=0; $i<$cwks; $i++)
{
echo "<td>Week $wks[$i]</td>";
}
echo "</tr>";
while($nrow=mysql_fetch_array($res))
{
$compn=$nrow[0];
$tsize=$nrow[1];
$hsize=$nrow[2];
$func=$nrow[3];
$st=$nrow[4];
$ed=$nrow[5];
$number++;
$status=(1 & $number) ? 'Odd' : 'Even';
for ($i=0; $i<$cwks; $i++)
{
/* this is the problem query below*/
//query to get the number of tools that falls within the date range for each comp_name of each client. if a week falls outside the selected time range it should return null
$wkquery="SELECT number from $table WHERE (('$st'>='$bw[$i]' OR '$st'<='$ew[$i]') AND ('$ed'>='$bw[$i]'
OR '$ed'<='$ew[$i]')) AND comp_name='$compn' AND tool_size='$tsize' AND hole_size='$hsize' AND func='$func'
AND start='$st' AND end= '$ed'";
$wkres=mysql_query($wkquery, $dblink) or die("query failed : " . mysql_error());
$wkrow=mysql_fetch_array($wkres);
if($wkrow[0]==null)
{
$numb[$i]=0;
}
else
{
$numb[$i]=$wkrow[0];
$diff=$func-$numb[$i];
if($diff<0 and $numb[$i]>0)
{
$bg="#FF0000";
}
}
}
if ($status=='Odd')
{
echo "<tr class=\"odd\">";
}
else
{
echo "<tr class=\"even\">";
}
echo " <td >$compn</td>
<td >$tsize</td>
<td >$hsize</td>
<td>$func</td>";
for ($i=0; $i<$cwks; $i++)
{
if($numb[$i]==0)
{
echo "<td>$numb[$i]</td>";
}
else
{
echo "<td bgcolor=\"$bg\">$numb[$i]</td>";
}
}
echo "</tr>";
}
echo "</table>";
}
echo "</table>";
}
}
?>
</div>
</form>
</div>
<div id="menu">
<?php
if($admin=="Y"wink
{
menuA();
}
else if($admin=="N"wink
{
menuO();
}
?>
</div>
<div id="footer">
Designed by <b>Ashley Akinpelu</b>.<br>Email:&nbsp;<a href="mailto:g99ma@mun.ca" class="footer">g99ma@mun.ca</a>
</div>
</div>
</body>
</html>

Programming / Re: Help Needed With Mysql/php Date Query by g99ma(f): 9:00pm On Sep 12, 2007
@Fikzy

Thanks for post. Will let you have my code in a bit , need to put some more comments so you'll understand what I am trying to do.
Programming / Help Needed With Mysql/php Date Query by g99ma(f): 7:37pm On Sep 12, 2007
Hello,

I have been battling to get this query right for almost 2 days but it seems this battle is one I will not win.

I basically want to display a weekly report for a selected time range. So let's say for instance the selected date range is Sept 12, 2007 to Oct 16, 2007. Based on php date manipulation I was able to get the weeks of year that falls within this date range and they are as follows:

week 37 (Sept 9 - Sept 15)
week 38 (Sept 16 - Sept 22)
week 39 (Sept 23 - Sept 29)
week 40 (Sept 30 - Oct 06)
week 41 (Oct 07 - Oct 13)
week 42 (Oct 14 - Oct 20)

Now in my database table let's say there is an entry (Number of books rented e.g) with start date of Sept 13,2007 and end date of Oct 13, 2007. What I am trying to do is run a select query to pick this entry where the week range falls within the start and end dates in the database. So basically I should have the same value returned for week 37 through 41 and 42 should return null.

Thanks for your anticipated help. Any alternative approach is highly welcome.
Jokes Etc / Re: Check Out The Most Annoying Website by g99ma(f): 1:26pm On Jul 19, 2007
pressing ctrl alt del should help stop this , kinda irritating if you don't know how to stop this though.
Jokes Etc / Steal Me If You Dare by g99ma(f): 1:16pm On Jul 19, 2007
The owner must really love this bicycle , lol

Jokes Etc / A Daughters Letter To Her Mother by g99ma(f): 5:19pm On Jul 18, 2007
A mother passing by her daughter's bedroom was astonished to see the bed was nicely made and everything was picked up. Then she saw an envelope propped up prominently on the center of the bed. It was addressed, "Mom." With the worst premonition, she opened the envelope and read the letter with trembling hands:

Dear Mom: It is with great regret and sorrow that I'm writing you. I had to elope with my new boyfriend because I wanted to avoid a scene with Dad and you. I've been finding real passion with Ahmed and he is so nice-even with all his piercings, tattoos, beard, and his motorcycle clothes. But it's not only the passion Mom, I'm pregnant and Ahmed said that we will be very happy. He already owns a trailer in the woods and has a stack of firewood for the whole winter. He wants to have many more children with me and that's now one of my dreams too. Ahmed taught me that marijuana doesn't really hurt anyone and we'll be growing it for us and trading it with his friends for all the cocaine and ecstasy we want. In the meantime, we'll pray that science will find a cure for AIDS so Ahmed can get better; he sure deserves it!! Don't worry Mom, I'm 15 years old now and I know how to take care of myself. Someday I'm sure we'll be back to visit so you can get to know your grand children.

Your daughter, Judith

PS: Mom, none of the above is true. I'm over at the neighbor's house. I just wanted to remind you that there are worse things in life than my report card that's in my desk center drawer. I love you! Call when it is safe for me to come home.
Jokes Etc / More Jokes by g99ma(f): 4:20pm On Jul 18, 2007
One day old man Stumpy and his wife Martha went to the Illinois State Fair. There is this man selling plane rides in his single prop show plane for $10 per person. Stumpy looks to Martha and says, "Martha, I think I really should try that." Martha replies, "I know you want to Stumpy, but we have a lot of bills, and you know the money is tight, and $10 is $10." So Stumpy goes without. Over the next few years they return every year, and the same thing, Stumpy wants to ride, but Martha says no money.

Finally, when Stumpy and Martha are both about 70 years old, Stumpy looks to Martha, and says, "Martha, I'm 70 now, and I don't know if I'll ever get the chance again, so I just have to have a ride in that there airplane." Martha replies in the same old fashion, and Stumpy kind of slumps down. The pilot is standing near by and overhears the conversation,

The pilot pipes up, "Excuse me folks, I couldn't help but hear your situation, and I have a deal for you. I'll take both of you up together, and if you can both make the entire trip without saying a word, or even making the slightest sound, I'll give the ride for free. But if either of you make a sound, its $10 each." Well, Martha and Stumpy look at each other, and agree to take the ride.

The pilot takes them up, and starts to do loop de loops, twists, dives, climbs and spins. No sound. The pilot lands the plane, looks back at Stumpy and says, "Sir, I have to hand it to ya, you didn't make even the slightest sound and that was my best stuff." Stumpy looks back at the pilot and says, "Well, I was gonna say something when Martha fell out, but $10 is $10!"

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

An Amish boy and his father were visiting a mall. They were amazed by almost everything they saw, but especially by two shiny, silver walls that could move apart and back together again. The boy asked his father, "What is this, Father?" The father [never having seen an elevator] responded "Son, I have never seen anything like this in my life, I don't know what it is."

While the boy and his father were watching wide-eyed, an old lady in a wheel chair rolled up to the moving walls and pressed a button. The walls opened and the lady rolled between them into a small room. The walls closed and the boy and his father watched small circles of lights with numbers above the walls light up. They continued to watch the circles light up in the reverse direction.

The walls opened up again and a beautiful 24-year-old woman stepped out. The father said to his son, "Go get your mother."
Jokes Etc / She(ree)mote by g99ma(f): 5:29pm On Jul 17, 2007
Every man's dream - a new variation on an unoriginal theme

Jokes Etc / Re: Where The Heart Is by g99ma(f): 5:15pm On Jul 17, 2007
Shortly after her wedding, the newlywed wife is complaining to her mother about her husband's insatiable sexual appetite.

"He wants to do it 15 times a day, anytime, anyplace, anywhere -- on the table, on the stairs, on the sofa, in the car, in the morning, in the afternoon, and in the evening. I can barely walk anymore!"

The mother advises her daughter to tell him that she has her period, which seems like a good idea.

So that evening, when the husband comes home from work, he proceeds to UnCloth himself and his wife, when she stops him.

"I'm sorry sweetie, but it's that time of the month."

The husband gets up, looks at his wife, and says, "It's all good honey. I understand." He puts on a robe and walks away.

The wife is somewhat surprised at the mature reaction of her husband, until a few minutes later he returns holding two glasses and a bottle of champagne.

So she asks, "What's going on, dear?"

"We're celebrating!" he replies.

"Celebrating? What exactly are we celebrating?" she asks.

"Anal sex week!"
Jokes Etc / Re: Where The Heart Is by g99ma(f): 5:12pm On Jul 17, 2007
Everybody on earth dies and goes to heaven. God comes and says, "I want the men to make two lines. One for the men that dominated their women on earth and the other for the men that were dominated by their women. Also, I want all the women to go with St. Peter."

Said and done, the next time God looked, the women are gone and there are two lines. The line of the men that were dominated by their women was 100 miles long, and in the line of men that dominated their women, there was only one man.

God got mad and said, "You men should be ashamed of yourselves. I created you in my image and you allowed yourselves to be dominated by your mates. Look at the only one of my sons that stood up and made me proud. Learn from him! Tell them my son, how did you manage to be the only one in this line?"

And the man replied, "I don't really know. My wife just told me to stand here."
Jokes Etc / Re: Where The Heart Is by g99ma(f): 5:08pm On Jul 17, 2007
A man and his wife were having some problems at home and were giving each other the silent treatment. Suddenly, the man realized that the next day, he would need his wife to wake him at 5:00 AM for an early morning business flight. Not wanting to be the first to break the silence (and LOSE), he wrote on a piece of paper, "Please wake me at 5:00 AM " He left it where he knew she would find it.

The next morning, the man woke up, only to discover it was 9:00 AM and he had missed his flight. Furious, he was about to go and see why his wife hadn't wakened him, when he noticed a piece of paper by the bed. The paper said, "It is 5:00 AM. Wake up."

Men are not equipped for these kinds of contests.
Jokes Etc / Where The Heart Is by g99ma(f): 5:00pm On Jul 17, 2007
Hazel was a 93-year-old woman, particularly despondent over the death of her husband, Earl. She decided she would just kill herself and join him in death. Thinking that it would be best to get it over quickly, she took out Earl's old Army pistol and made the decision to shoot herself in the heart, since it was so badly broken in the first place.

Not wanting to miss the vital organ and become a vegetable and burden someone, she called her doctor's office to inquire as to just exactly where the heart would be on a woman.

The doctor told her, "Your heart would be just below your left breast."

Later that night Hazel was admitted to the hospital with a gunshot wound to her left knee.
Educational Services / Re: Sitp(shell Intensive Training Program) Is Out?i Got Serioous Question, Pls Help? by g99ma(f): 5:42pm On Jul 10, 2007
Collinz,

I was one of the first batch intakes of sitp (1999). With everything in life there is always the pros and cons , most of the guys/gals in my set got jobs with spdc but some people did not. Some did not even make it through the training. So basically it's a risk , you really have to dig deep within yourself and decide if you are willing to take that risk knowing the probability of eventually getting a job with spdc is not exactly 100%.

M

(1) (of 1 pages)

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 80
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.