只有当它们=特定字段时,才会输出结果


Out results only if they = certain fields

基本上,我有一个允许用户发布主题的页面,该表的字段是。。

  • 主题id
  • 类别
  • 子类别(_C)
  • 主题数据
  • 发布者
  • 张贴

我正在尝试在输出页面上配置页面,以便如果用户发布到类别"常规"&sub_category"Stuff",然后它将显示所有包含类别名称General&Stuff的Sub_cat。

这是我的代码,它目前显示一个空白的白色屏幕,没有错误。

$sql = "SELECT users.user_id, users.username, users.profile, topics.topic_id,
         topics.category, topics.sub_category, topics.topic_data, 
         topics.posted_by, topics.posted, topics.view, topics.reply 
          FROM users, topics 
         WHERE topics.category = '" . $_GET['category'] . "' 
           AND topics.sub_category = '" . $_GET['sub_category'] . "'
      ORDER BY topics.posted DESC";
$result = mysql_query($sql);
while($rows = mysql_fetch_array($result)){

使用上面的代码,如果我转到topics.php?category=General,它成功地显示了General的记录,但不确定这是否是正确的方法。

编辑

在发布主题的地方,我将标题重定向从topics.php更改为topics.php?category=$category&sub_category=$sub_category,这很有效,但我在系统上有两个用户,现在它发布的数据与两个用户相同。。。。

Location: topics.php?category=$category&sub_category=$sub_category