Php 当url id放置在浏览器地址上而无需登录时,如何获取特定的数据表
我是一个新手,刚刚开始学习,我有一个困惑,无法从表到url id获取数据表, 我想在编写url时从表中获取数据,例如localhost/index.php?=user='username',表将根据url用户名显示 这是表格样本 内容表Php 当url id放置在浏览器地址上而无需登录时,如何获取特定的数据表,php,mysql,Php,Mysql,我是一个新手,刚刚开始学习,我有一个困惑,无法从表到url id获取数据表, 我想在编写url时从表中获取数据,例如localhost/index.php?=user='username',表将根据url用户名显示 这是表格样本 内容表 code_content | judul_content | deskripsi | nama_lengkap 2 abc tes1 john 3
code_content | judul_content | deskripsi | nama_lengkap
2 abc tes1 john
3 efg tes2 gerald
4 hij tes3 john
username | password | nama_lengkap
user1 123 john
user2 234 gerald
用户表
code_content | judul_content | deskripsi | nama_lengkap
2 abc tes1 john
3 efg tes2 gerald
4 hij tes3 john
username | password | nama_lengkap
user1 123 john
user2 234 gerald
当我编写这个urllocalhost/index.php?=user=user2时,我希望显示这个输出
**
**
通过
如何在不登录的情况下根据url用户显示表格
谢谢因为您试图从两个表中检索数据,所以您必须在两个表之间建立关系(将内容中的用户id作为外键传递),然后您可以借助URL传递的值轻松检索数据 用户表 目录 localhost/index.php?=user='username'
我看没有问题。此外,当我写一个问题时,我试图给出一个人们可以搜索该问题的标题。但是,有时这是不可能的。问号(??)帮助我们快速找到问题。我应该更改表格吗?我添加了如何。。可以吗?url应该是
/index.php?user=user2
在我的表user中内容表user\u id columnuser\u id中没有用户id我从user表中得到NULL没有id。。。可以吗?不,当我键入url index.php时,user\u id不应该为空?user=username结果是SELECT content.judul\u content,userapp.nama_lengkap来自userapp.kode_user=content.content_id WHERE userapp.username='SELECT username FROM userapp WHERE username='nama'LIMIT 1'我刚得到它,对查询做了一些更改,并将另一个脚本与上面的查询结合起来。。。谢谢你的帮助。。。
id | username | password | nama_lengkap
1 user1 123 john
2 user2 234 gerald
user_id | kode_content | judul_content | deskripsi | nama_lengkap
1 2 abc tes1 john
2 3 efg tes2 gerald
if(isset($_GET['user'])) {
$user_name = $_GET['user'];
$check_user = "SELECT username FROM user WHERE username = '$user_name' LIMIT 1";
if(!empty($check_user))
{
$user_data = "SELECT contents.judul_content, users.nama_lengkap
FROM users
INNER JOIN contents
ON users.id=contents.user_id
WHERE users.username = '$check_user'";
print_r ($user_data);
}else{
echo "No User Found."
}
}