gpt4 book ai didi

php - 如何在以前的 SQL 查询结果的 SQL 查询中传递 PHP 变量?

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

我正在处理一个 PHP 项目,我遇到了一个问题,我无法传递 PHP 变量来执行由先前执行的查询产生的 SQL 查询。

<?php 
include"config.php";
$sqli = mysql_query("select * from police_data where p_id='$name_perm'",$conn);
//name_perm is again a variable that stores the police id. It works very fine.

while($rows = mysql_fetch_array($sqli))
{
echo $rows['location'].'<br>';
$e = intval($rows['location']+ 6);
$f = intval($rows['location']- 6);
echo $e.'<br>'; // I received the location in INT format
} echo $f.'<br>';

$sql = mysql_query("select * from data_get having LatLong between 90 and 95",$conn) ;
// This query gives me result. But instead of 90 and 95 I want to pass $e and $f.
// When I tried so it doesn't provide any result.

while($row = mysql_fetch_array($sql))
{
echo '<table>';

echo '<tr>';
echo '<td><img height="300" width="240" src="data:image;base64,'.$row['Image']. '"></td>';
echo '<td>'.$row['LatLong'].'</td>';
echo '<td>'.$row['month'].'</td></tr>';
echo '</table>';
}
?>

上面的代码是获取某个范围内的图像数据。

最佳答案

这会起作用:

mysql_query("select * from data_get having LatLong between $e and $f",$conn) ;

但是请停止使用mysql_query,它是deprecated

关于php - 如何在以前的 SQL 查询结果的 SQL 查询中传递 PHP 变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33207476/

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