【发布时间】:2015-10-19 05:55:08
【问题描述】:
我正在处理一个 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>';
}
?>
以上代码是检索某个范围内的图像数据。
【问题讨论】:
标签: php mysql sql-server having nested-queries