请帮助,我想基于id获取mysql信息,例如我有一个论坛,并且如果forum_id
相同,则在行中有parent_id
和parent_id
我想要与forum_id
一起使用,然后显示来自该论坛的信息,希望您能得到我。
例如,显示线程是否在Game / Maps / CS上,并且父ID为Maps,然后向我显示Game Name和Maps。另外,如果可能的话,我希望查询按ID显示信息,例如$ row [parent_id] [name]或简单的$ row [parent_id] [forum_id] [name],我希望有人打电话给我:)谢谢。
代码如下:
<?php
include('paginator.class.php');
try {
$conn = new PDO('mysql:host=localhost;dbname=test', 'test', 'test');
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$num_rows = $conn->query('SELECT COUNT(*) FROM frm_topics')->fetchColumn();
$pages = new Paginator($num_rows,9,array(10,25,50,100,250,'All'));
echo $pages->display_pages();
echo "<span class=\"\">".$pages->display_jump_menu().$pages->display_items_per_page()."</span>";
$stmt = $conn->prepare('SELECT frm_topics.tid,frm_topics.title,frm_topics.posts,frm_topics.title,frm_topics.starter_id,frm_topics.starter_name,frm_topics.views,frm_topics.forum_id,frm_forums.id,frm_forums.name,frm_forums.icon,frm_forums.parent_id FROM frm_topics INNER JOIN frm_forums ON frm_topics.forum_id = frm_forums.id ORDER BY frm_topics.tid DESC LIMIT :start,:end');
$stmt->bindParam(':start', $pages->limit_start, PDO::PARAM_INT);
$stmt->bindParam(':end', $pages->limit_end, PDO::PARAM_INT);
$stmt->execute();
$result = $stmt->fetchAll();
echo "<table><tr><th>Game</th><th>Title</th><th>Category</th><th>Coms</th><th>Views</th><th>Author</th></tr>\n";
foreach($result as $row) {
echo "<tr class='row1'><td><img src='https://www.link.com/images/games/$row[13]'/></td><td>$row[1]</td><td><a href='https://www.link.com/cat/$row[14]' class=\"nav\">$row[12]</a><a href='https://www.link.com/cat/$row[15]' class=\"nav\">$row[13]</a> <a href='https://www.link.com/cat/$row[7]' class=\"nav\">$row[9]</a></td><td>$row[3]</td><td>$row[4]</td></tr>\n";
}
echo "</table>\n";
echo $pages->display_pages();
echo "<p class=\"paginate\">Page: $pages->current_page of $pages->num_pages</p>\n";
echo "<p class=\"paginate\">SELECT * FROM frm_topics LIMIT $pages->limit_start,$pages->limit_end (retrieve records $pages->limit_start-".($pages->limit_start+$pages->limit_end)." from table - $pages->total_items item total / $pages->items_per_page items per page)";
} catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
?>