Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/13/2023 in all areas

  1. Alternatively, assuming they all have same rigid structure, ... $fp = file('weather.html', FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); $data = []; foreach ($fp as $line) { switch (substr($line, 0, 4)) { case '<!--' : if ($line[4]!=' ') { $section = substr($line, 4, -8); } break; case '<td>' : list($name, $value) = getData($line); $data[$section][$name] = $value; break; default : continue 2; } } function getData($line) { $l = substr($line, 4, -5); return explode('</td><td>', $l); } // View the results echo '<pre>' . print_r($data, 1) . '</pre>'; giving ... $data = Array ( [MISCELLANEOUS] => Array ( [Name of Station] => AzureCove [City (from NOAA Setup)] => Garden City [State (from NOAA Setup)] => Utah [Elevation (from NOAA Setup)] => 5954 ft [Latitude (from NOAA Setup)] => 41° 56' 12" N [Longitude (from NOAA Setup)] => 111° 23' 20" W [Date on the PC] => 03/13/23 [Time on the PC] => 4:06a [UTC Time] => 10:06a [UTC Date] => 03/13/23 [Date on the Station] => 03/13/23 [Time on the Station] => 4:05a [Sunrise Time] => 7:41a [Sunset Time] => 7:30p [Current Weather Forecast *] => Partly cloudy with little temperature change. [Current Moon Phase] => Last Quarter [EMC] => --- [EMC Unit] => % [Air Density] => 0.0842 [Air Density Unit] => lb/cu.ft ) [INSIDE TEMPERATURE] => Array ( [Inside Temperature] => 42.5 [High Inside Temperature] => 43.6 [Time of High Inside Temperature] => 12:00a [Low Inside Temperature] => 42.5 [Time of Low Inside Temperature] => 3:41a [High Monthly Inside Temperature] => 45.4 [Low Monthly Inside Temperature] => 39.4 [High Yearly Inside Temperature] => 45.7 [Low Yearly Inside Temperature] => 39.4 ) [OUTSIDE TEMPERATURE] => Array ( [Outside Temperature] => 15.1 [High Outside Temperature] => 21.7 [Low Outside Temperature] => 15.1 [Time of High Outside Temperature] => 12:00a [Time of Low Outside Temperature] => 4:04a [High monthly Outside Temperature] => 46.1 [Low monthly Outside Temperature] => -11.3 [High yearly Outside Temperature] => 46.1 [Low yearly Outside Temperature] => -12.5 ) . . . )
    1 point
  2. For parsing the HTML and extracting the data, look into DOMDocument. Load the document, use getElementsByTagName to find the rows by grabbing the tr tags. Then for each row, use getElementsByTagName to get the cells by grabbing the td tags. Use textContent on the cells to extract the values.
    1 point
  3. ppname doesn't come from $_POST. You defined it here: #file name with a random number so that similar dont get replaced $ppname = rand(1000,10000)."-".$_FILES["file2"]["name"];
    1 point
  4. You'd just do the same thing, but with the variable for your file name. $ppname = mysqli_real_escape_string($conn , $ppname); However, this is not really the way you should be handling this issue. Instead, you should be using prepared statements with bound parameters. $sql = " UPDATE users SET band2 = ?, audio1 = ? WHERE id = ? "; $stmt=mysqli_prepare($conn, $sql); $stmt->bind_param('ssi', $_POST['band2'], $ppname, $id); $stmt->execute();
    1 point
  5. I'm asking a stupid question but way are you validating a person name? The Late Prince would had have trouble with that. 🤣 The person's age is another head scratcher. If some of that information is not right simply have it where a person can edit the information, have it idiot proof like the person's age as an example or have a confirmation page.
    0 points
This leaderboard is set to New York/GMT-04:00
×
×
  • 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.