我正在创建论坛类型页面,我正在使用教程来帮助我。这个教程都在mysql中,所以它已经过时了,但是我已经能够改变一切到此为止。我不知道为什么,但我在使用这段代码时感到非常糟糕。我首先开始尝试通过准备好的声明来正确地做到这一点,但它根本不起作用。现在我尝试做一个基本的查询来获取一些东西,但是使用以下代码,我得到了else语句 - echo "<p>This topic does not exist.</p>";
$con = mysqli_connect("localhost", "", "", "");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$cid = $_GET['cid'];
$tid = $_GET['tid'];
$userid = ( isset( $_SESSION['user'] ) ? $_SESSION['user'] : "" );
//Start Here
$sql = mysqli_query($con, "SELECT * FROM forum_topics category_id='".$cid."' AND id='".$tid."'LIMIT 1");
$numrows = $stmt->num_rows;
if($numrows == 1){
echo "<table width='100%'>";
if ( $_SESSION['user'] ) {
echo "<tr><td colspan='2'><input type='submit' value='Add Reply' onClick=\"window.location =
'forum_post_reply.php?cid=".$cid."$tid=".$tid."'\"> <hr />";
} else {
echo "<tr><td colspan='2'><p>Please log in to add your reply</p><hr /></td></tr>";
}
foreach($sql as $row) {
$sql2 = mysqli_query($con, "SELECT * FROM forum_posts category_id='".$cid."' AND topic_id='".$tid."'");
foreach($sql2 as $row2) {
echo "<tr><td valign='top' style='border: 1px solid #000000;'>
<div style='min-height: 125px;'>".$row['topic_title']."<br />
by ".$row2['post_creator']." - " .$row2['post_date']. "<hr />" . $row2['post_content'] ."</div></td>
<td width='200' valign='top' align='center' style='border: 1px solid #000000;'>User Info Here!</td></tr>
<tr><td colspan='2'><hr /></td></tr>";
}
}
} else {
echo "<p>This topic does not exist.</p>";
}
有谁看到有什么问题?如果有人想要,我可以添加我试图做的准备好的声明。
我发布这个,这是我试图复制视频的屏幕截图。