Page 1 of 1
CODE GONE CRAZY aka need help please
Posted: Sun Dec 12, 2010 6:21 pm
by spag
I need help a php code...i have a text file that contains 5 columns, the first column is the month ( 1 1 1 1 2 2 2 ......) the second column is each day of the month, the third column is the year the , the fourth column is high temperatures and the fifth column in the low temperatues....the problem is that i need to determine how many days of the month the temperate was below 32 and how many days the temperature was above 90 and the output should be three columns wiht hte months the number of days below 32...i also have no code to provide because all my codes that i have tried are dead ended
Re: CODE GONE CRAZY aka need help please
Posted: Sun Dec 12, 2010 6:32 pm
by Jonah Bron
Well, I can't do the whole thing for you, but I can get you going. Here's the query you'll need for the first:
Code: Select all
SELECT * FROM mytable WHERE low_temp < 32
And here's your second query
Code: Select all
SELECT * FROM mytable WHERE high_temp > 90
Do you see how it works? Obviously, you need to change the table name and column names to the way they are in your database...
Also:
Forum Rules wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
Re: CODE GONE CRAZY aka need help please
Posted: Sun Dec 12, 2010 6:53 pm
by spag
Using the text file, write a PHP application that will count for each month the
number of days for which the maximum temperature was above 90°F and the minimum temperature
was below 32°F.
the code is:
1 1 35 19
1 2 29 18
1 3 31 15
1 4 35 22
1 5 32 19
1 6 38 23
1 7 42 23
output
mon <32 >90
1 26 0
Re: CODE GONE CRAZY aka need help please
Posted: Sun Dec 12, 2010 6:54 pm
by spag
i have the input and read from codes done
Re: CODE GONE CRAZY aka need help please
Posted: Sun Dec 12, 2010 7:09 pm
by spag
the columns are
store number invoice number amount 1 amount 2
1 1 32 87
1 2 33 45
1 3 14 56
1 4 90 34
1 5 100 45
1 6 33 75
2 1 36 25
2 2 72 35
2 31 92 65
Re: CODE GONE CRAZY aka need help please
Posted: Sun Dec 12, 2010 7:13 pm
by Jonah Bron
spag wrote:Using the text file, write a PHP application that will count for each month the
number of days for which the maximum temperature was above 90°F and the minimum temperature
was below 32°F...
Are you asking us to do it for you?
Re: CODE GONE CRAZY aka need help please
Posted: Sun Dec 12, 2010 7:16 pm
by califdon
It appears that he's asking us to do his school assignment.
Re: CODE GONE CRAZY aka need help please
Posted: Sun Dec 12, 2010 7:30 pm
by spag
no not at all
i just dont know to start
i have this so far
but
Code: Select all
$in=fopen("data.txt",'r');
$out=fopen("GDD2001.csv",'w');
$count1=0;$a1=0;
echo " Run <br/>";
for ($i=0; $i<366; $i++)
{ fscanf($in,"%u %u %u %f %f %f %f",$m,$d,$y,$h,$l,$rain,$snow);
if ($m =="1")
{if ($h <32)
{$a1= 1;}
else
{$a1=0;}}
echo $m. " ".$d. " ".$h." ".$a1. "<br/>";
}
fclose($in);
fclose($out);
and my issue is that i have no clue how to extract the total amount for month one and that when i run it it provides me with all the months in stead of month 1
Re: CODE GONE CRAZY aka need help please
Posted: Sun Dec 12, 2010 9:04 pm
by califdon
It's not my purpose to accuse you of something you're not guilty of, but when I read, "Using the text file, write a PHP application that will ...", it certainly sounds like an assignment. If not from a teacher, then perhaps in a book you're studying. We could probably give you a lot more help if you would explain what you're trying to do. It sounds like two unrelated projects. Why are you using a text file, to begin with? It sounds like the sort of thing that would use a MySQL database, ordinarily. If we understand your situation, we may be able to help you.