gpt4 book ai didi

php - 如何在MySQL中应用真实度?

转载 作者:行者123 更新时间:2023-11-30 22:33:50 25 4
gpt4 key购买 nike

它显示了几种疾病。我只想根据我输入的内容在数据库中检索最近的疾病。然后,结果是狼疮和麻疹

<?php

include('connect.php');

//Function to sanitize values received from the form. Prevents SQL injection

//Sanitize the POST values


$symptom1 = $_POST['symptom1'];
$symptom2 = $_POST['symptom2'];
$symptom3 = $_POST['symptom3'];
$symptom4 = $_POST['symptom4'];

$sql = mysql_query("SELECT disease FROM diseases WHERE
symptom1 LIKE '%". $symptom1."%' OR symptom1 LIKE '%". $symptom2."%' OR symptom1 LIKE '%". $symptom3."%' OR symptom1 LIKE '%". $symptom4."%' AND
symptom2 LIKE '%". $symptom1."%' OR symptom2 LIKE '%". $symptom2."%' OR symptom2 LIKE '%". $symptom3."%' OR symptom2 LIKE '%". $symptom4."%' AND
symptom3 LIKE '%". $symptom1."%' OR symptom3 LIKE '%". $symptom2."%' OR symptom3 LIKE '%". $symptom3."%' OR symptom3 LIKE '%". $symptom4."%' AND
symptom4 LIKE '%". $symptom1."%' OR symptom4 LIKE '%". $symptom2."%' OR symptom4 LIKE '%". $symptom3."%' OR symptom4 LIKE '%". $symptom4."%'");

while($row = mysql_fetch_array($sql))
{
echo $row['disease'];
}
//end of while loop

?>

query code

error

最佳答案

$query="
SELECT
disease,
(
symptom1 LIKE '%" . $symptom1 . "%'
OR symptom1 LIKE '%" . $symptom2 . "%'
OR symptom1 LIKE '%" . $symptom3 . "%'
OR symptom1 LIKE '%" . $symptom4 . "%'
) + (
symptom2 LIKE '%" . $symptom1 . "%'
OR symptom2 LIKE '%" . $symptom2 . "%'
OR symptom2 LIKE '%" . $symptom3 . "%'
OR symptom2 LIKE '%" . $symptom4 . "%'
) + (
symptom3 LIKE '%" . $symptom1 . "%'
OR symptom3 LIKE '%" . $symptom2 . "%'
OR symptom3 LIKE '%" . $symptom3 . "%'
OR symptom3 LIKE '%" . $symptom4 . "%'
) + (
symptom4 LIKE '%" . $symptom1 . "%'
OR symptom4 LIKE '%" . $symptom2 . "%'
OR symptom4 LIKE '%" . $symptom3 . "%'
OR symptom4 LIKE '%" . $symptom4 . "%'
) AS `score`
FROM
diseases
HAVING `score` > 0
ORDER BY `score` DESC";

关于php - 如何在MySQL中应用真实度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33115159/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com