我已经走得更远了,我想已经回答了我自己的问题。我发现研究起来有点棘手,因为我不了解 features/api/scripts/etc 的所有不同术语和名称。但我只需要阅读mysqli_connect() 的文档,我将代码设置如下,现在我已将数据库中的所有数据提取到我的 html/php 文件中的单词中。
从这里我想我可以重写代码以首先按日期对其进行排序,然后当然可以将最新帖子放在每个页面的顶部等。
我还可以允许用户点击“类型”并仅查看喜剧。
这里是用于将数据解析到我的 index.php 文件中的代码:
<?php
$servername = "127.0.0.1";
$username = "root";
$password = "yourpasswordhere";
$dbname = "yourdatabasenamehere";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id, type, title FROM releases";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - Type: " . $row["type"]. " - Title " . $row["title"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>
我扩展了上述工作,让 php 脚本获取数据库中的所有条目,并为每个条目创建我曾经拥有的上一篇 html 文章。在 SELECT 语句中,我可以控制显示哪些类型的条目(例如,对于某个类别)。我是这样做的:
// make an html article based snippet (image, title, description, etc),
//once for each entry in the database table...
<?php
$servername = "127.0.0.1";
$username = "root";
$password = "somepassword";
$dbname = "somedatabasename";
// create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// check connection
if ($conn->connect_error) {
die("connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM releases ORDER BY id DESC";
$result = $conn->query($sql);
if ($result->num_rows > 0)
{
// output data of each row
while($row = $result->fetch_assoc())
{
echo '<section class="wrapper style1">';
echo '<div class="inner">';
echo '<header class="align-center">';
echo '<h2>'. $row["title"] . '</h2>';
echo '<div class="image fit">';
echo '<img src='. $row["imgurl"] .'>';
echo '</div> <p> RELEASE TITLE: ' . $row["title"] . '<br /> DATE POSTED: ' . $row["postdate"] . '<br /> DESCRIPTION: ' . $row["description"] . '</p>';
echo '<a href="'.$row["link"].'">DOWNLOAD LINK: '.$row["link"].'</a> <br />';
$NfoLink = $row["nfolink"];
if ($NfoLink != 'not found' && $NfoLink != '')
{
echo '<a href="'.$row["nfolink"].'">NFO LINK/MORE DOWNLOADS: '.$row["nfolink"].'</a>';
}
echo '</header>';
echo '</div>';
echo '</section>';
}
}
else
{
echo "0 results";
}
$conn->close();
?>