php - PHP showing someone's user profile by taking MYSQL infos in HTML
问题描述
include_once 'info.php';
$query = $config -> prepare("SELECT `ID`, `Info1`, `Info2`, `Info3`, `Info4`,`Info5`,`Info6`, `Info7` FROM `users` ORDER BY `ID` DESC LIMIT 9999999999");
if($query -> execute())
{
$query_results = $query->fetchAll();
} foreach( $query_results as $query_result ) {
}
<html>
<tbody>
<?php foreach( $query_results as $query_result ) {
?>
<tr>
<td><?php echo $query_result["ID"]; ?></td>
<td><?php echo $query_result["Info1"]; ?></td>
<td><?php echo $query_result["Info2"]; ?> <?php echo $query_result["Info3"];?> <?php echo $query_result["Info4"]; ?></td>
<td><?php echo $query_result["Info5"]; ?> </td>
<td><?php echo $query_result["Info6"]; ?></td>
<td><?php echo $query_result["Info7"]; ?></td>
<td> <a class="btn btn-success" href="profiles/<?php echo $query_result["ID"]; ?>">
<i class="halflings-icon white zoom-in"></i>
</td>
</tr>
<?php } ?></html>
Hello. The code from above is my searchperson.php (not included database conf and so on, it just how I echo every user from "users" inside a table.) And inside my table, I have an eye (iclass) which I can click on it and redirect me to www.domain.com/users/ID
My question is, how can I make only ONE page, static page, which will show ID's infos?
Exemple: I click on ID1, a new page www.domain.com/user/1 will pop up. I don't have any folder named "1". And I don't want to create any folder for every user. I just want to show ID 1's informations on www.domain.com/user/1
And if I click on ID2, to show ID 2's information on www.domain.com/user/2. (Or, www.domain.com/user?2, it doesn't matter.)
解决方案
If you aren't using a framework or front controller pattern (single entrypoint for your app), then you can use an Apache rewrite, something like this:
RewriteEngine On
RewriteRule ^/user([^/]*)$ /user-info.php?id=$1 [L]
推荐阅读
- javascript - 在不覆盖当前语言环境的情况下定义 Moment.js 语言环境
- xml - 如何修复这些 XML 错误?
- javascript - 我需要帮助了解用于网络抓取的 soup.find() 以及它如何准确地找到正确的信息
- c - #176-D 表达式无效”当我创建函数指针数组时出现警告。这是怎么回事?
- c++ - OpenGL:一个简单的彩色三角形 glDebugCallback 错误
- python - 脚本在 Anaconda Prompt 中有效,但不能通过命令行
- java - Springboot 应用程序在 Cloud Foundry 上崩溃而没有任何崩溃日志
- lua - 向数组添加名称,检查数组以查看名称是否存在,运行代码
- json - 如何在 JavaScript 中使用访问令牌格式化 API 调用
- python - 如何用 Opencv Python 计算图像中有多少个白色“球”?