Php 搜索中的其他结果/注释

Php 搜索中的其他结果/注释,php,database,search,Php,Database,Search,想知道是否有可能,当你从一个网站搜索一个页面和数据列表时,你是否不仅可以将它们排列在最相关的第一位,而且还可以显示一个值 例如,您搜索之前输入的有关您销售的柠檬水的数据。你跟踪多个因素,如“一天中的时间、温度、月份等”。你想知道一周后你将卖出多少,所以你在“一天中的时间、温度、月份等”中输入值 从理论上讲,我希望能够根据相关性调出所有输入的数据,并根据以前的记录向您显示您将出售的估计。有什么想法吗 谢谢这需要一个算法。我不会写所有的代码,但我不介意给出一些指导:)。 获取数据的html与设置数据

想知道是否有可能,当你从一个网站搜索一个页面和数据列表时,你是否不仅可以将它们排列在最相关的第一位,而且还可以显示一个值

例如,您搜索之前输入的有关您销售的柠檬水的数据。你跟踪多个因素,如“一天中的时间、温度、月份等”。你想知道一周后你将卖出多少,所以你在“一天中的时间、温度、月份等”中输入值

从理论上讲,我希望能够根据相关性调出所有输入的数据,并根据以前的记录向您显示您将出售的估计。有什么想法吗


谢谢

这需要一个算法。我不会写所有的代码,但我不介意给出一些指导:)。 获取数据的html与设置数据的html相同,只是它将调用一个单独的.php脚本

以下示例可用于指导。它仅使用温度计算预测销售额:

//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;
//从表单中获取今天的温度,并查询数据库中的所有温度
$todaysTemp=$_POST[‘温度’];
$tempRange=20//表中的每个温度必须在计算中包含的今天温度范围内
$result=$connection->query(“从myTable中选择温度、销售额”);
//通过将该温度添加到总计,然后按包含的总计行进行细分,计算平均温度
$temp_sales_array=array();
foreach($结果为$行){
如果(绝对值($todaysTemp-$row['temperature'])