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'] )
);
精彩评论