Jump to content

siclines

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

siclines's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. thanks, i tried that before, but I put the ( before value, not row. Thanks again
  2. So I have a table with data in it, but I want to change the value by multiplying it. So here is the code showing the data in the table: echo "<td width='100' align='center'>" . $row[value* 3.2] . "</td>"; The value is 1.1 and the output from the code above is 837 when it should be 3.52, what am I doing wrong? Thanks for your help
  3. I am using the code below to display a text file: <?php $filename="http://weather.noaa.gov/cgi-bin/fmtbltn.pl?file=forecasts/marine/coastal/an/anz451.txt"; //open file $fp = fopen($filename,'r'); //loop through each line in the file while($line=fgets($fp)) { //output current text file line print $line."<br>"; } //close file handle fclose($fp); ?> Is there a way to show only the lines 12 - 40?
  4. hi everyone when using a switch statement, how do you write the case to see if the value is between x and y, then equal value=m? For example, the direction South, in degrees on a compass is 159 to 203, so how do you write the case to read 176 and determine it's south? case ($row[wdir] >= 159): $row[wdir] = 'South'; break; thanks for your help
  5. the table is always cleared, so the id number is always different, can i make that a function and call the function to convert the value and then display it?
  6. my database is 6 records in table with 19 fields, I want to display all the 6 rows of data, which i have and work, but the data is stored as a number and I want to display the name (i.e. North) when i return the record.
  7. So if $wind_direction is a value from a record in a database, the code would be $result = mysql_query("SELECT wind_direction FROM northbuoy"); $wind_direction = $result if($wind_direction >= minimum for letter && $wind_direction <= maximum for letter){ echo('North'); }elseif($wind_direction >= minimum for letter && $wind_direction <= maximum for letter){ echo('South'); }elseif($wind_direction >= minimum for letter && $wind_direction <= maximum for letter){ echo('East'); }elseif($wind_direction >= minimum for letter && $wind_direction <= maximum for letter){ echo('West'); }
  8. I have weather data that shows the wind direction in degrees, i want to read the data, and display the letter name for the direction. For example, if the value is 164, I want to display South because the number is between 155 and 200. How would I do that?
  9. That worked, thank you very much for your help. Much shorter then what I was trying. What if I only wanted the first five rows?
  10. Thanks for all your help, I made some changes, but now it only insert a blank record. No data. I read the function explode on php.net, what am I missing? $file = "http://www.ndbc.noaa.gov/data/5day2/44004_5day.txt"; $fp = fopen($file, "r"); $data = fread($fp, filesize($file)); fclose($fp); $output = explode(" ", $output); foreach($output as $var) { $Year = $Year; $Month = $Month; $Day = $Day; $Hour = $Hour; $Min = $Min; $WindDir = $WindDir; $WindSpeed = $WindSpeed; $Gust = $Gust; $WaveHT = $WaveHT; $DPD = $DPD; $APD = $APD; $MWD = $MWD; $Press = $Press; $Atemp = $Atemp; $Wtemp = $Wtemp; $Dewp = $Dewp; $Vis = $Vis; $ptdy = $ptdy; $Tide = $Tide; $tmp = explode(" ", $var); foreach ($output as $newrow) mysql_query("INSERT INTO buoy44 (Year,Month,Day,Hour,Min,WindDir,WindSpeed,Gust,WaveHT,DPD,APD,MWD,Press,Atemp,Wtemp,Dewp,Vis,ptdy,Tide) VALUES('$Year','$Month','$Day','$Hour','$Min','$WindDir','$WindSpeed','$Gust','$WaveHT','$DPD','$APD','$MWD','$Press','$Atemp','$Wtemp','$Dewp','$Vis','$ptdy','$Tide')") or die("Insert failed: " . mysql_error()); }
  11. thanks for your reply, I am trying to insert each line as a row in the database.
  12. here is the code excluding my connection string: <?php $file = "http://www.ndbc.noaa.gov/data/5day2/44004_5day.txt"; $fp = fopen($file, "r"); $data = fread($fp, filesize($file)); fclose($fp); $output = str_replace("\t|\t", "|", $data); $output = explode("\n", $output); mysql_query("INSERT INTO buoy44 (Year,Month,Day,Hour,Min,WindDir,WindSpeed,Gust,WaveHT,DPD,APD,MWD,Press,Atemp,Wtemp,Dewp,Vis,ptdy,Tide) VALUES('$Year','$Month','$Day','$Hour','$Min','$WindDir','$WindSpeed','$Gust','$WaveHT','$DPD','$APD','$MWD','$Press','$Atemp','$Wtemp','$Dewp','$Vis','$ptdy','$Tide')") or die("Insert failed: " . mysql_error()); } ?> (please use tags when posting code)
  13. I am able to read the data from the text file, and I can print the text on the screen, I just can't get it in the db. I tried various examples, I appreaciate everyone's time and I do not expect anyone to write the code for me, just trying to understand what I am doing wrong. I am not getting any errors, just a blank screen.
  14. Hey everyone, I am trying to read a text file from NOAA, http://www.ndbc.noaa.gov/data/5day2/44004_5day.txt, and insert it into mysql database. I have read various examples, but have had no luck. Can anyone post an example of this process? Thanks, sic
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.