アルゴリズムが必要になります。私はすべてのコードを書くつもりはありませんが、いくつかのガイダンスを与えることは気にしません:)。データを取得するための html は、別の .php スクリプトを呼び出す点を除いて、データを設定するための html と同じです。
以下の例は、ガイダンスとして使用できます。気温のみを使用して予測売上を計算します。
//get todays temperature from form, and query database for all temperatures
$todaysTemp = $_POST['temperature'];
$tempRange = 20; //each temperature in the table must be within this range of todaysTemp to be included in calculation
$result = $connection->query("SELECT temperature, sales FROM myTable");
//calculate average temperature by adding this temp to total, then diving by total rows included
$temp_sales_array = array();
foreach($result as $row){
if( abs($todaysTemp - $row['temperature']) < tempRange){
$temp_sales_array[$row['temperature']] = $row['sales'];
}
}
//calculate predicted sales, by getting array value thats closest to todays temperature
$closest=key($temp_sales_array[0]);
foreach($temp_sales_array as $row){
if( abs($todaysTemp - key($row)) < closest ){
closest = key($row);
$predicted_sales = $row;
}
}
//show predicted sales
echo $predicted_sales;