...

View Full Version : assign variable to html cell value in table



muppet77
01-18-2012, 10:58 PM
using both separate tables in this file

www.maidenerleghweather.com/GFS/18z-17-01.html

how easy is it to write a code to assign a variable to a cell value?

eg I want to grab the 3rd row and the 3rd column.

is php any use?

Spookster
01-19-2012, 01:04 AM
Unless you plan to retrieve those static table values using parameters in the URL from a hyperlink or put the values in a form it would be kind of pointless as your script is already completed execution when the page gets to the browser.

Maybe it would be better if you explained what it is you are trying to do.

muppet77
01-19-2012, 06:17 AM
thanks.

I want to do various things such as count how many times the max temp falls under 6c or the few point under zero.

I want to then add these totals together.

Spookster
01-19-2012, 10:09 AM
Where are you getting the data from that goes into the table? Is it coming from a database? If so you should do your calculations when you retrieve that data before you populate the table.

muppet77
01-19-2012, 05:17 PM
its from a third party so I have no control.

the only thing that i do have is the html script, which is accessed via the url posted above.


any ideas?

Spookster
01-19-2012, 10:24 PM
its from a third party so I have no control.

the only thing that i do have is the html script, which is accessed via the url posted above.


any ideas?

Oh ok I guess I misunderstood then. So that site you linked to is not yours and you want to grab the data from their static table to use for some calculations?

muppet77
01-19-2012, 10:43 PM
yes, that's right.

is this possible?

Spookster
01-19-2012, 11:11 PM
Ok in that case you will need to parse their html file then. Hopefully they are consistent with how they format it otherwise this will be a pointless effort.

Here is another thread where someone was looking to do something similar where they were given thousands of html files that they had to parse to grab specific data out of tables and save it to a CSV file. You will want to take a very similar approach. If you can use the DOM to parse it that would be the simplest otherwise you will have to get creative with using regular expressions to grab the data.

http://www.codingforums.com/showthread.php?t=244867

muppet77
01-19-2012, 11:20 PM
thanks, I have no idea what that is nor where to start. sorry!

Spookster
01-19-2012, 11:37 PM
Well to get started obviously the first thing you would need to be able to do is use PHP to grab the html from that other site. You can do this a few ways. One way is to use the file_get_contents() function. Something like:

$html = file_get_contents('http://www.maidenerleghweather.com/GFS/18z-17-01.html');

You could also use cURL to grab it http://php.net/manual/en/book.curl.php

Once you have their page in a string you need to parse it using one of the 2 methods shown in the other thread I posted a link to. I'd probably start with trying DOM if their HTML is well formed enough to use DOM. If not regular expressions will always work but are definitely not easy to define.

mlseim
01-20-2012, 12:13 AM
Didn't I answer this one before ... on how to parse your static HTML table?

I swear this was the same topic:
http://www.codingforums.com/showthread.php?t=248092

I had a heck of a time parsing it too ... what an HTML mess.
If I remember correctly, I even suggested that you contact them and
ask them if they can provide an API or at least an XML file of data.
It would so easy for them to do that ... one small script.

Even if they could give you a link to a CSV file ... even that would be OK.
What you're doing seems so obsolete and messed-up. It's 2012 for cripe sakes!



.

muppet77
01-20-2012, 06:27 AM
mLseim, yes if you recall it was only possible to extract the values with hyperlinks attached to them.

I'd really like to pick and choose the data columns.

those parse tutorials look tricky. I don't really get which tags I am looking for.

for example which tags do I strip out for then temperature?

mlseim
01-20-2012, 02:00 PM
Which temperature columns(s) are you trying to get?
Let me know what the column heading is on the ones you want.

muppet77
01-20-2012, 05:11 PM
max temp
min temp
td
total precip
500-1000thickness
850mb temp
500mb temp

mlseim
01-20-2012, 06:09 PM
the rows ...

td
850mb
500mb

all have the same <HTML> in them.
I'm stuck on that now ... maybe I'll think of something later on.


EDIT: question ...
Will there always be the two table sections?


.

muppet77
01-20-2012, 06:17 PM
yes always two tables and always the same number of columns and rows in each.

good luck and thank you.

mlseim
01-20-2012, 09:04 PM
Try this one:

If all you see is: Array(), try a different URL.
I've noticed their pages don't always load.



<?php

// site url
$site_url = "http://wxweb.meteostar.com/sample/sample_C.shtml?text=EGRR/#";

//$site_url = "www.maidenerleghweather.com/GFS/18z-17-01.html";

// With my webhost, I am not allowed to use fopen() or get_contents.
// So, I use the preferred CURL method. This depends on your webhost and PHP revision.

// curl get contents
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $site_url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
$lines = array();
$lines = explode("\n", $file_contents);

// define a couple of arrays,
// one for the time, and the other for the actual value.

$row=array();

$i1=0;
$i2=0;
$i3=0;
$i4=0;
$i5=0;
$i6=0;
$i7=0;
$i8=0;
$i9=0;
$i10=0;
$i11=0;
$i12=0;
$flag=0;

// loop thru and find the specific text within each line.

foreach($lines as $line) {

// time
if($flag==1 && strpos($line,"</TABLE>")){
$flag=2;
}
if($flag==1){
$string2=strip_tags($line);
$row['time'][$i1]=$string2;
$i1++;
}
if(strpos($line,"Valid <BR>Time")){
$flag=1;
}

// max temp
if($flag==2 && strpos($line,"</TABLE>")){
$flag=3;
}
if($flag==2){
$string2=strip_tags($line);
$row['maxtemp'][$i2]=$string2;
$i2++;
}
if(strpos($line,"CENTER NOWRAP>Max Temp")){
$flag=2;
}

// min temp
if($flag==3 && strpos($line,"</TABLE>")){
$flag=4;
}
if($flag==3){
$string2=strip_tags($line);
$row['mintemp'][$i3]=$string2;
$i3++;
}
if(strpos($line,"CENTER>Min Temp")){
$flag=3;
}

// td
if($flag==4 && strpos($line,"</TABLE>")){
$flag=5;
}
if($flag==4){
$string2=strip_tags($line);
$row['tdx'][$i4]=$string2;
$i4++;
}
if(strpos($line,"NOWRAP>Td")){
$flag=4;
}

// total precip
if($flag==5 && strpos($line,"</TABLE>")){
$flag=6;
}
if($flag==5){
$string2=strip_tags($line);
$row['totalprecip'][$i5]=$string2;
$i5++;
}
if(strpos($line,"Total Precip(mm)")){
$flag=5;
}

// 500-1000 thickness
if($flag==6 && strpos($line,"</TABLE>")){
$flag=7;
}
if($flag==6){
$string2=strip_tags($line);
$row['thkns'][$i6]=$string2;
$i6++;
}
if(strpos($line,"500-1000 THKNS")){
$flag=6;
}

// 850mb Temp
if($flag==7 && strpos($line,"</TABLE>")){
$flag=8;
}
if($flag==7){
$string2=strip_tags($line);
$row['mb850'][$i7]=$string2;
$i7++;
}
if(strpos($line,"850mb Temp")){
$flag=6;
}

// >500mb Temp
if($flag==8 && strpos($line,"</TABLE>")){
$flag=9;
}
if($flag==8){
$string2=strip_tags($line);
$row['mb500'][$i8]=$string2;
$i8++;
}
if(strpos($line,">500mb Temp")){
$flag=8;
}

// ============= NEXT TABLE ==================

// time
if($flag==9 && strpos($line,"</TABLE>")){
$flag=10;
}
if($flag==9){
$string2=strip_tags($line);
$row['time'][$i1]=$string2;
$i1++;
$row['tdx'][$i4]=0;
$i4++;
}
if($flag==1){
// nothing
}
else{
if(strpos($line,"Valid <BR>Time")){
$flag=9;
}
}

// max temp
if($flag==10 && strpos($line,"</TABLE>")){
$flag=11;
}
if($flag==10){
$string2=strip_tags($line);
$row['maxtemp'][$i2]=$string2;
$i2++;
}
if($flag==2){
// nothing
}
else{
if(strpos($line,"CENTER>Max Temp")){
$flag=10;
}
}

// min temp
if($flag==11 && strpos($line,"</TABLE>")){
$flag=12;
}
if($flag==11){
$string2=strip_tags($line);
$row['mintemp'][$i3]=$string2;
$i3++;
}
if($flag==3){
// nothing
}
else{
if(strpos($line,"CENTER>Min Temp")){
$flag=11;
}
}

// total precip
if($flag==12 && strpos($line,"</TABLE>")){
$flag=13;
}
if($flag==12){
$string2=strip_tags($line);
$row['totalprecip'][$i5]=$string2;
$i5++;
}
if($flag==5){
// nothing
}
else{
if(strpos($line,"Total Precip(mm)")){
$flag=12;
}
}

// 500-1000 thickness
if($flag==13 && strpos($line,"</TABLE>")){
$flag=14;
}
if($flag==13){
$string2=strip_tags($line);
$row['thkns'][$i6]=$string2;
$i6++;
}
if($flag==6){
// nothing
}
else{
if(strpos($line,"500-1000 THKNS")){
$flag=13;
}
}

// 850mb Temp
if($flag==14 && strpos($line,"</TABLE>")){
$flag=15;
}
if($flag==14){
$string2=strip_tags($line);
$row['mb850'][$i7]=$string2;
$i7++;
}
if($flag==7){
// nothing
}
else{
if(strpos($line,"850mb Temp")){
$flag=14;
}
}

// >500mb Temp
if($flag==15 && strpos($line,"</TABLE>")){
$flag=16;
}
if($flag==15){
$string2=strip_tags($line);
$row['mb500'][$i8]=$string2;
$i8++;
}
if($flag==8){
// nothing
}
else{
if(strpos($line,">500mb Temp")){
$flag=15;
}
}

}


// Display the actual arrays ...
print_r($row);
echo "<br><br>";

for($x=0; $x<count($row['time']); $x++){
echo "TIME: {$row['time'][$x]} <br />";
echo "MAX TEMP: {$row['maxtemp'][$x]} <br />";
echo "MIN TEMP: {$row['mintemp'][$x]} <br />";
echo "TD: {$row['tdx'][$x]} <br />";
echo "TOTAL PRECIP: {$row['totalprecip'][$x]} <br />";
echo "THKNS: {$row['thkns'][$x]} <br />";
echo "850mb: {$row['mb850'][$x]} <br />";
echo "500mb: {$row['mb500'][$x]} <br /><br />";
}

?>






.

muppet77
01-20-2012, 10:08 PM
good news!

i think it has worked!

view the output at

http://www.maidenerleghweather.com/wine.php

(don't ask why it's called wine)

so how do i start to refer to each cell value?
which array is which?

thank you so much!

mlseim
01-21-2012, 04:18 AM
You can comment-out all the echo stuff ..
That's there just to see what is in the array.

All values are stored in one 2-dimensional array, called $row.

Now, you just refer to any row number and the column name.
In this case, I think it's like 75 rows.
The rows start at zero (0)

Example, you want to know the Max Temp from row 10 ...

echo $row['maxtemp'][9];

Remember it starts at zero, so 9 is the 10th line of your list.

You want to get an average of the Max Temp?

for($x=0; $x<count($row['maxtemp']); $x++){
$sum=$sum+$row['maxtemp'][$x];
}
echo "The average Max Temp is: ";$sum/count($row['maxtemp']);

Like that ...

muppet77
01-21-2012, 07:30 AM
wow. thanks.

that's one area I am still learning about cycling through the data. for commands and while commands etc.

how would I write

if temp is less than 5, then add one to a count?

I suspect I'd have to remove the degrees sign first, but I could find the length first of each array, then return the first (length minus one) characters.

any ideas on the if temp < 5 then increase the count?

muppet77
01-21-2012, 07:40 AM
would it be

for($x =0; $x< count($row[' maxtemp']);
$x+ +){
if ($ row['maxtemp'][ $x] < 5) { $count=$ count+ 1
}};

but with the degree sign removed as described before?

muppet77
01-21-2012, 07:47 AM
so substitute

substr ( $ row['maxtemp'][ $x] , 0, strlen($ row['maxtemp'][ $x]) -1 )

in the above script?

muppet77
01-21-2012, 09:15 AM
You can comment-out all the echo stuff ..
That's there just to see what is in the array.

All values are stored in one 2-dimensional array, called $row.

Now, you just refer to any row number and the column name.
In this case, I think it's like 75 rows.
The rows start at zero (0)

Example, you want to know the Max Temp from row 10 ...

echo $row['maxtemp'][9];

Remember it starts at zero, so 9 is the 10th line of your list.

You want to get an average of the Max Temp?

for($x=0; $x<count($row['maxtemp']); $x++){
$sum=$sum+$row['maxtemp'][$x];
}
echo "The average Max Temp is: ";$sum/count($row['maxtemp']);

Like that ...

and i couldn't get this to work.

where in the code does it go?

EDIT - probably as there are degree signs still it returns nothing!

d'oh!

i will try to remove them....

muppet77
01-21-2012, 09:26 AM
I am trying to add 1 to a tally count ($tally) if the temp is < 5.

Here is the code i came up with


for($x=0; $x<count($row['maxtemp']); $x++){

if (substr($row['maxtemp'][$x],0,strlen($row['maxtemp'][$x])-6) < 5) { $tally = $tally + 1;
}}


echo "The tally is: "; $tally;


by removing 6 characters that gets rid of the " &deg;" after the number.

however, i get no value returned (but i do get the text part returned).

if i do


echo substr($row['maxtemp'][$x],0,strlen($row['maxtemp'][$x])-6);

it prints all the numbers correctly. i can even add or subtract from them, so they are numeric values in that form.

i just can't get the tally count to go up if the maxtemp is < 5.

any ideas?

thanks

muppet77
01-21-2012, 06:32 PM
got it.

my formula was correct. the original needed an extra echo in it. d'oh


echo "The average Max Temp is: ";$sum/count($row['maxtemp']);



echo "The average Max Temp is: ";
echo $sum/count($row['maxtemp']);

mlseim
01-21-2012, 06:48 PM
Sorry I forgot about that degree symbol.
That could be eliminated before it gets in the array.

After every line that looks like this:
$string2=strip_tags($line);

You add this line ... in red ...
$string2=strip_tags($line);
$string2=str_replace(" &deg;","",$string2);

You really only need to add that for the sections that have the degree symbol.
But if you aren't sure, you can add it to all of them ... it won't hurt anything.


.

muppet77
01-21-2012, 08:23 PM
thanks mate.

i have noticed that the max and min temps from the SECOND table aren't correct. they look like reasonable numbers but don't tally with what they should be. I can't see where they are coming from??

the other values in the 2nd table are correct, nevertheless.

mlseim
01-21-2012, 11:00 PM
I checked it ... min/max columns seem OK to me on both tables ...

Here's my test:
http://www.catpin.com/parse.php

Give me a new URL to try.
The one that is failing for you.

Some more thoughts ...
Put this line at the end somewhere ...
echo count($row['maxtemp'])." rows found";

See if the number of rows matches the number of rows on both tables together.
Maybe the "for" loop need to be:
for($x=0; $x<=count($row['maxtemp']); $x++){
instead of:
for($x=0; $x<count($row['maxtemp']); $x++){

And finally, their data changes ... so maybe you're caching an old page.
Refresh it.


.

muppet77
01-22-2012, 11:47 AM
ok, here is the script i am using. NB i have changed the url at the top.

i have also made a few changes.

dew point does not exist in the 2nd table, so i have substituted the max temp in as dew point in the 2nd table and called it $newdew.

in the print out, "yes" is printed if the condition is met.

conditions to be met are

max and min <=5
dew <=0 (or newdew <=2 as i estimate it will be 2C higher than maxT)
precip >0
thickness <523
850T <=-5
500T <=-25

it just doesn't seem to be picking up the 2nd table.

at the end i have tried to add together the individual scores.


<?php

// site url
//$site_url = "http://wxweb.meteostar.com/sample/sample_C.shtml?text=EGRR/#";

$site_url = "www.maidenerleghweather.com/GFS/18z-17-01.html";

// With my webhost, I am not allowed to use fopen() or get_contents.
// So, I use the preferred CURL method. This depends on your webhost and PHP revision.

// curl get contents
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $site_url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
$lines = array();
$lines = explode("\n", $file_contents);

// define a couple of arrays,
// one for the time, and the other for the actual value.

$row=array();

$i1=0;
$i2=0;
$i3=0;
$i4=0;
$i5=0;
$i6=0;
$i7=0;
$i8=0;
$i9=0;
$i10=0;
$i11=0;
$i12=0;
$flag=0;

// loop thru and find the specific text within each line.

foreach($lines as $line) {

// time
if($flag==1 && strpos($line,"</TABLE>")){
$flag=2;
}
if($flag==1){
$string2=strip_tags($line);
$string2=str_replace(" &deg;","",$string2);
$row['time'][$i1]=$string2;
$i1++;
}
if(strpos($line,"Valid <BR>Time")){
$flag=1;
}

// max temp
if($flag==2 && strpos($line,"</TABLE>")){
$flag=3;
}
if($flag==2){
$string2=strip_tags($line);
$string2=str_replace(" &deg;","",$string2);
$row['maxtemp'][$i2]=$string2;
$i2++;
}
if(strpos($line,"CENTER NOWRAP>Max Temp")){
$flag=2;
}

// min temp
if($flag==3 && strpos($line,"</TABLE>")){
$flag=4;
}
if($flag==3){
$string2=strip_tags($line);
$string2=str_replace(" &deg;","",$string2);
$row['mintemp'][$i3]=$string2;
$i3++;
}
if(strpos($line,"CENTER>Min Temp")){
$flag=3;
}

// td
if($flag==4 && strpos($line,"</TABLE>")){
$flag=5;
}
if($flag==4){
$string2=strip_tags($line);
$string2=str_replace("&deg;","",$string2);
$row['tdx'][$i4]=$string2;
$i4++;
}
if(strpos($line,"NOWRAP>Td")){
$flag=4;
}

// total precip
if($flag==5 && strpos($line,"</TABLE>")){
$flag=6;
}
if($flag==5){
$string2=strip_tags($line);
$string2=str_replace(" &deg;","",$string2);
$row['totalprecip'][$i5]=$string2;
$i5++;
}
if(strpos($line,"Total Precip(mm)")){
$flag=5;
}

// 500-1000 thickness
if($flag==6 && strpos($line,"</TABLE>")){
$flag=7;
}
if($flag==6){
$string2=strip_tags($line);
$string2=str_replace(" &deg;","",$string2);
$row['thkns'][$i6]=$string2;
$i6++;
}
if(strpos($line,"500-1000 THKNS")){
$flag=6;
}

// 850mb Temp
if($flag==7 && strpos($line,"</TABLE>")){
$flag=8;
}
if($flag==7){
$string2=strip_tags($line);
$string2=str_replace(" &deg;","",$string2);
$row['mb850'][$i7]=$string2;
$i7++;
}
if(strpos($line,"850mb Temp")){
$flag=6;
}

// >500mb Temp
if($flag==8 && strpos($line,"</TABLE>")){
$flag=9;
}
if($flag==8){
$string2=strip_tags($line);
$string2=str_replace(" &deg;","",$string2);
$row['mb500'][$i8]=$string2;
$i8++;
}
if(strpos($line,">500mb Temp")){
$flag=8;
}

// ============= NEXT TABLE ==================

// time
if($flag==9 && strpos($line,"</TABLE>")){
$flag=10;
}
if($flag==9){
$string2=strip_tags($line);
$string2=str_replace(" &deg;","",$string2);
$row['time'][$i1]=$string2;
$i1++;
$row['tdx'][$i4]=0;
$i4++;
}
if($flag==1){
// nothing
}
else{
if(strpos($line,"Valid <BR>Time")){
$flag=9;
}
}

// max temp
if($flag==10 && strpos($line,"</TABLE>")){
$flag=11;
}
if($flag==10){
$string2=strip_tags($line);
$string2=str_replace(" &deg;","",$string2);
$row['maxtemp'][$i2]=$string2;
$row['newdew'][$i4]=$string2;
$i2++;
$i4++;
}
if($flag==2){
// nothing
}
else{
if(strpos($line,"CENTER>Max Temp")){
$flag=10;
}
}


// min temp
if($flag==11 && strpos($line,"</TABLE>")){
$flag=12;
}
if($flag==11){
$string2=strip_tags($line);
$string2=str_replace(" &deg;","",$string2);
$row['mintemp'][$i3]=$string2;
$i3++;
}
if($flag==3){
// nothing
}
else{
if(strpos($line,"CENTER>Min Temp")){
$flag=11;
}
}

// total precip
if($flag==12 && strpos($line,"</TABLE>")){
$flag=13;
}
if($flag==12){
$string2=strip_tags($line);
$string2=str_replace(" &deg;","",$string2);
$row['totalprecip'][$i5]=$string2;
$i5++;
}
if($flag==5){
// nothing
}
else{
if(strpos($line,"Total Precip(mm)")){
$flag=12;
}
}

// 500-1000 thickness
if($flag==13 && strpos($line,"</TABLE>")){
$flag=14;
}
if($flag==13){
$string2=strip_tags($line);
$string2=str_replace(" &deg;","",$string2);
$row['thkns'][$i6]=$string2;
$i6++;
}
if($flag==6){
// nothing
}
else{
if(strpos($line,"500-1000 THKNS")){
$flag=13;
}
}

// 850mb Temp
if($flag==14 && strpos($line,"</TABLE>")){
$flag=15;
}
if($flag==14){
$string2=strip_tags($line);
$string2=str_replace(" &deg;","",$string2);
$row['mb850'][$i7]=$string2;
$i7++;
}
if($flag==7){
// nothing
}
else{
if(strpos($line,"850mb Temp")){
$flag=14;
}
}

// >500mb Temp
if($flag==15 && strpos($line,"</TABLE>")){
$flag=16;
}
if($flag==15){
$string2=strip_tags($line);
$string2=str_replace(" &deg;","",$string2);
$row['mb500'][$i8]=$string2;
$i8++;
}
if($flag==8){
// nothing
}
else{
if(strpos($line,">500mb Temp")){
$flag=15;
}
}
}




// Display the actual arrays ...
print_r($row);
echo "<br><br>";

for($x=0; $x<count($row['time']); $x++){

echo "<br /> TIME: {$row['time'][$x]} <br />";
echo "MAX TEMP: {$row['maxtemp'][$x]} <br />";
if ($row['maxtemp'][$x] < 6) {echo "yes <br />";}
echo "MIN TEMP: {$row['mintemp'][$x]} <br />";
if ($row['mintemp'][$x] < 6) {echo "yes <br />";}
echo "TD: {$row['tdx'][$x]} <br />";
if ($row['tdx'][$x] < 1) {echo "yes <br />";}
echo "TOTAL PRECIP: {$row['totalprecip'][$x]} <br />";
if ($row['totalprecip'][$x] > 0) {echo "yes <br />";}
echo "THKNS: {$row['thkns'][$x]} <br />";
if ($row['thkns'][$x] < 523) {echo "yes <br />";}
echo "850mb: {$row['mb850'][$x]} <br />";
if ($row['mb850'][$x] < -4) {echo "yes <br />";}
echo "newdew: {$row['newdew'][$x]} <br />";
if ($row['newdew'][$x] < 3) {echo "yes <br />";}
echo "500mb: {$row['mb500'][$x]} <br />";
if (trim($row['mb500'][$x]) < -24) {echo "yes <br /><br />";}}



for($x=0; $x<=count($row['maxtemp']); $x++){
if ($row['maxtemp'][$x] < 6) {$maxt= $maxt+ 1;}}
echo "The maxt is: ";
echo $maxt;

for($x=0; $x<=count($row['mintemp']); $x++){
if ($row['mintemp'][$x] < 6) {$mint= $mint+ 1;}}
echo "The mint is: ";
echo $mint;

for($x=0; $x<=59; $x++){
if ($row['tdx'][$x] < 1) {$tdx = $tdx + 1;}}

for($x=60; $x<=count($row['tdx']); $x++){
if ($row['newdew'][$x] < 3) {$newdew = $newdew + 1;}}
echo "The dew is: ";
$dew = $newdew + $tdx;
echo $dew;


for($x=0; $x<=count($row['totalprecip']); $x++){
if ($row['totalprecip'][$x] >= 0) {$totalprecip = $totalprecip + 1;}}
echo "The totalprecip is: ";
echo $totalprecip;

for($x=0; $x<=count($row['thkns']); $x++){
if ($row['thkns'][$x] < 523) {$thkns = $thkns + 1;}}
echo "The thkns is: ";
echo $thkns;

for($x=0; $x<=count($row['mb850']); $x++){
if ($row['mb850'][$x] < -4) {$mb850 = $mb850+ 1;}}
echo "The mb850 is: ";
echo $mb850;

for($x=0; $x<=count($row['mb500']); $x++){
if ($row['mb500'][$x] < -24) {$mb500 = $mb500+ 1;}}
echo "The mb500 is: ";
echo $mb500;

$score = ($mint + $maxt + $tdx + $thkns + $totalprecip + $mb850 + $mb500);
echo " score is : ";
echo $score;

?>

muppet77
01-24-2012, 08:34 PM
all sorted!

the php was correct and my Excel sheet that i relied upon to check the results was wrong!!!

d'oh.

thanks mlseim, i have learnt so much here, especially about looping commands in php

;-)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum