【发布时间】:2017-07-11 06:56:16
【问题描述】:
我的功能正常工作,我似乎无法获得正确的 IF 条件来包装它。我想要实现的只是在 WHILE 有任何要显示的内容时创建链接列表。
所以如果我在线程 id 3 上并且它有 2 个插件线程 id 4,5 它将创建:
<ul>
<li><a href="showthread.php?t=4">Link 4</a></li>
<li><a href="showthread.php?t=5">Link 5</a></li>
</ul>
如果我在线程 2 上并且它没有插件线程 ID,它应该什么也不返回。
这是我目前没有条件的。
$addonid = $db->query_read ("
SELECT drc.threadid AS threadid
FROM `" . TABLE_PREFIX . "modsys_settings` AS drc
LEFT JOIN `" . TABLE_PREFIX . "thread` AS thread
ON(drc.mod_addons=" . $threadinfo['threadid'] . ")
WHERE thread.threadid IN (" . $threadinfo['threadid'] . ")
");
$post['addons'] = '<ul>';
while ($addons = $db->fetch_array ($addonid)) {
$ci_counter = $db->query_read ("
SELECT drc.mod_addons AS addon, drc.threadid, thread.threadid AS threadid, thread.title AS threadtitle
FROM `" . TABLE_PREFIX . "modsys_settings` AS drc
LEFT JOIN `" . TABLE_PREFIX . "thread` AS thread ON(drc.mod_addons=" . $threadinfo['threadid'] . ")
WHERE thread.threadid IN (" . $addons['threadid'] . ")
");
$counter = $db->fetch_array ($ci_counter);
$post['addons'] .= '<li><a href="showthread.php?t=' . $addons['threadid'] . '">'. $counter['threadtitle'] .'</a></li>';
}
$post['addons'] .= '</ul>';
【问题讨论】:
标签: mysql if-statement while-loop conditional-statements vbulletin