<? while($blog2 = mysql_fetch_array($blog))
{
$tag = ("select * from blogtag_ref inner join blogtag on blogtag_ref.tag_id = blogtag.tag_id where blogtag_ref.blog_id = '".$blog2['blog_id']."' ") or die(mysql_error());
?>
<table width="1040" border="0" cellspacing="0" cellpadding="10" align="center">
<tr>
<td><div class="blogtitle"><? echo $blog2['subject']; ?></div></td>
</tr>
<tr>
<td><div class="blogdate"><? echo $date; ?></div> //
<? while($tag2 = mysql_fetch_array($tag))
{ ?>
<div class="blogtag"><? echo $tag2['tag']; ?></div> /
<? } ?>
它给了我Warning: mysql_fetch_assoc() expects parameter 1 to be resource
我知道我的SQL是正确的,如果我回复$tag
...我在phpmyadmin中复制粘贴...它给了我结果......
是因为我不能在一段时间内放一会儿?
答案 0 :(得分:2)
您所指的变量($ tag)不是结果,mysql_fetch_array()需要来自mysql_query的结果
$tag = mysql_query("select ....") or die('yeah');
while($tag2 = mysql_fetch_array($tag))
答案 1 :(得分:0)
您需要先评估SQL语句,然后才能从中获取数据。插入查询信息'mysql_query'。
$tag = ("select * from blogtag_ref ....
$result = mysql_query($tag, $db_connection);
然后,您可以使用$result
:
while($tag2 = mysql_fetch_array($result)) {
答案 2 :(得分:0)
$tag = ("select * ...
应该阅读
$tag = mysql_query("select * ...