从索引页面读取并显示来自数据库的txt文件的内容

问题描述:

在php中如何使索引页面从保存在TXT文件夹中的文本文件中读取,并且文本名称已经保存在mysqli数据库中,对于php和数据库。 这里是数据库表从索引页面读取并显示来自数据库的txt文件的内容

enter image description here

+1

你有试过什么吗? –

+0

php mysql从db中选择数据http://www.w3schools.com/php/php_mysql_select.asp –

+2

这不是一个“代码对我来说”。谷歌它自己,并问你是否卡住 –

从SQL文本文件名,然后使用file_get_contents()来获取文本文件的内容。

$servername = "localhost"; 
$username = "username"; 
$password = "password"; 
$dbname = "myDB"; 

// Create connection 
$connection= new mysqli($servername, $username, $password, $dbname); 
    $query = mysqli_query($connection, "SELECT name FROM new_record"); 
    while ($row = mysqli_fetch_array($query)) { 
     $fileName = $row['name']; 
     $fileContents = file_get_contents("/TXT/$fileName"); 
     echo $fileContents; 
    } 
+0

hes要求从数据库获取 –

+0

他问如何使文本文件保存到TXT文件夹中,当文本文件名是在SQL数据库中的索引页读取。 – Janno

+0

以及如何从数据库中获取文本文件名? –