Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php MySQL-使用表a作为位置从表b获取信息=_Php_Mysql - Fatal编程技术网

Php MySQL-使用表a作为位置从表b获取信息=

Php MySQL-使用表a作为位置从表b获取信息=,php,mysql,Php,Mysql,我这里有这段代码,但它不起作用,我只是在显示器上显示“无进程”,我试图从表B中获取图像URL,同时使用表A中的标题引用。关于我做错了什么,有什么帮助吗 <?php $gettop="SELECT * FROM feeddb ORDER BY ID DESC LIMIT 0 , 3"; $gettop2=mysql_query($gettop) or die("Processing Error"); while($gettop3=mysql_fetch_array($gettop2)) {

我这里有这段代码,但它不起作用,我只是在显示器上显示“无进程”,我试图从表B中获取图像URL,同时使用表A中的标题引用。关于我做错了什么,有什么帮助吗

<?php
$gettop="SELECT * FROM feeddb ORDER BY ID DESC LIMIT 0 , 3";
$gettop2=mysql_query($gettop) or die("Processing Error");
while($gettop3=mysql_fetch_array($gettop2))
{
echo "<div class='rt'></div>";
echo "<div class='right_articles'>";
$getimg="SELECT * FROM feedus where tit=".$gettop3['title'];
$getimg2=mysql_query($getimg) or die("No Process");
$getimg3=mysql_query_fetch_array($getimg2);
echo "<p><img src='$getimg3[img]' width='60' height='60' class='image' /><b>Feed: $gettop3[title]</b><br/>$gettop3[feedpost]<br><br><br><br></p>";
echo "</div>";
}
?>

在第二次查询后尝试回显
mysql\u error()。并选中
$getimg

编辑:

我想你应该在
$gettop3['title']
周围加上引号,比如

$getimg = sprintf(
 "SELECT * FROM feedus where tit='%s'"
 , mysql_real_escape_string( $gettop3['title'] )
);

您应该像这样引用
$gettop3['title']

$getimg="SELECT * FROM feedus where tit='".$gettop3['title']."'";

我在where子句中得到了“未知列‘hi’”,如果
$gettop3['title']
是一个字符串,它将在
$getimg
中被取消引号,这使它成为一个错误的查询。我已将其更改为:
$getimg=“SELECT*FROM feedus where tit=”。$gettop3['title']。“但是现在我没有收到任何错误消息。我在PHPMyAdmin中尝试了它,但它返回了以下结果:
显示第0-0行(总共1行,查询耗时0.0002秒)
使用
SELECT*FROM feedus,其中tit='test'LIMIT 0,30
可以
echo$getimg
并在PHPMyAdmin中运行输出吗?可能feedus中没有匹配的数据
它显示
显示第0-0行(总共1行,查询耗时0.0001秒)
并显示其下方列表中的行。嗨,是我要找的人。echo outputs
SELECT*FROM feedus,其中tit='hi'LIMIT 0,30
我在上面执行此操作的URL是:,它将显示在右侧的橙色部分。
var\u dump($getimg3)
的输出是什么?当您查看页面的源代码时,标签是什么样子的?