私は、artistという名前の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 /ここで何を検索するのか分かりません。
私のコードで更新されているので、1つのプロファイルページをテンプレートとして作成し、そのコンテンツをテーブルからロードします。 – Krim