- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个名为艺术家的mySQL表,索引页面包含所有艺术家姓名的列表,我希望用户单击艺术家的姓名进入包含艺术家数据的个人资料页面,因此php将创建个人资料基于个人资料模板和艺术家 ID 的页面,而不是为每个艺术家创建数百个页面,我该怎么做
编辑:获取php页面代码
<?php
include("config.php"); //include config file
//sanitize post value
$page_number = filter_var($_POST["page"], FILTER_SANITIZE_NUMBER_INT, FILTER_FLAG_STRIP_HIGH);
//throw HTTP error if page number is not valid
if(!is_numeric($page_number)){
header('HTTP/1.1 500 Invalid page number!');
exit();
}
//get current starting point of records
$position = (($page_number-1) * $item_per_page);
//fetch records using page position and item per page.
$results = $mysqli->prepare("SELECT name, location, score, img FROM artists ORDER BY score DESC LIMIT ?, ?");
//bind parameters for markers, where (s = string, i = integer, d = double, b = blob)
//for more info https://www.sanwebe.com/2013/03/basic-php-mysqli-usage
$results->bind_param("ss", $position, $item_per_page);
$results->execute(); //Execute prepared Query
$results->bind_result($name, $location, $score, $img); //bind variables to prepared statement
//output results from database
while($results->fetch()){ //fetch values
echo "<a href=<div class=\"feed_item\">";
echo "<img src=\"img/" . $img . ".jpg\"class=\"feed_img\">";
echo "<h2 class=\"feed_title\">" . $name . "</h2>";
echo "<h4 class=\"feed_subtitle\">" . $location . "</h4>";
echo "</div>";
}
?>
我的表格中有 ID 列,我感到迷失,不知道在 google/here 中搜索什么。
最佳答案
如果您提供一些代码来显示您当前如何查询数据库以获取所有艺术家的列表,那么我们将能够为您提供更多帮助。
一般来说,您需要做的是执行查询,然后循环遍历每个结果。在循环中,您需要设置一个指向 artist.php?id=XX
的链接,其中 XX 是循环中特定艺术家的 ID。
然后,您可以创建一个名为 artist.php
的新脚本,该脚本具有一个查询来获取 GET 请求中发送的 ID。
例如
select * from artists where id='$id'
然后您可以执行此查询,获取该艺术家的结果,然后在屏幕上显示详细信息。
这是一个高层次的内容,但希望能让您了解需要采取的方法。
关于php - 动态创建包含不同数据的个人资料页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44485649/
我正在使用passport.js 为我的node.js 应用程序提供OAuth 身份验证。但我确实有一个疑问: 当我在身份验证时收到配置文件对象(当您定义 OAuth 策略时)时,该对象对于所有提供商
我正在尝试对 wordpress 布局进行解码/逆向工程。我正在浏览 CSS 文件,无法弄清楚这个长长的菜单 mumbo-jumbo 是什么! 我不是要任何人检查代码,而是让我知道我在看什么。这些似乎
所以我尝试制作一个包含私有(private)配置文件的 symfony 项目,并且我使用 FriendsOfSymfony,但是如果我创建两个用户,每个人都可以看到其他人上传的文件。我尝试在多个网站上
我正在编写一个需要使用已登录 G+ 用户的公开个人资料图片的 JS 应用。 如果我有用户 ID,我可以使用 Google+ API 查询个人资料数据。 https://developers.googl
我看过很多关于 facebook 身份验证的帖子,要么是旧的,要么不能正常工作。 然而,最终我在我的项目中做了一些可行但不完全的东西。这是我要求的代码 var facebookAuth
我是一名优秀的程序员,十分优秀!