开发者

MySQL - get information from table b using table a as where =

开发者 https://www.devze.com 2023-03-27 09:43 出处:网络
I have this code here, but it\'s not working I just get \"No Process\" on my display, I am trying to get the image URL from table B while using the title reference from table A. Any Help on what i am

I have this code here, but it's not working I just get "No Process" on my display, I am trying to get the image URL from table B while using the title reference from table A. Any Help on what i am doing wrong?

<?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' 开发者_如何学Pythonheight='60' class='image' /><b>Feed: $gettop3[title]</b><br/>$gettop3[feedpost]<br><br><br><br></p>";
echo "</div>";
}
?>


You should be quoting $gettop3['title'] like this

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


Try to echo mysql_error() after the second query. And check $getimg.

EDIT:

I guess you should add quotes around $gettop3['title'], something like

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

精彩评论

暂无评论...
验证码 换一张
取 消