基本上我有一个页面,允许用户发布主题,该表的字段是..
- 主题_id
- 类别
- 子类别
- 主题数据
- 发布者
- 已发布
我正在尝试在输出页面上配置页面,以便如果用户发布到类别“General”和 sub_category“Stuff”,它将显示包含类别名称 General 和 Sub_cat of Stuff 的所有记录。
这是我的代码,它当前显示空白屏幕,没有错误。
$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
有效,但我有 2系统上的用户,现在正在发布与两个用户相同的数据....
最佳答案
Location: topics.php?category=$category&sub_category=$sub_category
关于php - 仅当它们 = 某些字段时才输出结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17606039/