条件不是检索数据的时候

时间:2017-09-18 03:58:49

标签: php database mysqli output fetch

嗨,所以mysqli_query正在经历并且我想到了获取数据。但是,当稍后尝试输出数据时,它不会起作用。我的查询设置为仅检索数据,其中文件名(表单_' $ last_id' .php)与'链接'中的记录的值相同。我的数据库中的链接表的列。没有错误显示,我已经三倍检查我的mysqli表和列名称。这是代码:

获取数据:

<?php

$db_user = "root";
$db_pass = "";
$db_name = "music_reviews_database";
$db_host = "localhost";

$conn = mysqli_connect($db_host, $db_user, $db_pass, $db_name);

$filepath = $_SERVER['REQUEST_URI'];
$file = basename($filepath);

$q = mysqli_query($conn, 
    "SELECT album.Album, 
    artist.ArtistsName, 
    datereviewed.DateReviewed, 
    features.Features, 
    genre.Genre, 
    rating.Rating, 
    songname.SongName,
    link.Link,
    link.ID,
    comments.Comments
    FROM `link`
    INNER JOIN album ON album.ID = link.ID 
    INNER JOIN artist ON artist.ID = link.ID
    INNER JOIN datereviewed ON datereviewed.ID = link.ID
    INNER JOIN features ON features.ID = link.ID
    INNER JOIN genre ON genre.ID = link.ID
    INNER JOIN rating ON rating.ID = link.ID
    INNER JOIN comments ON comments.ID = link.ID
    INNER JOIN songname ON songname.ID = link.ID
    WHERE `Link`='$file'");
$row = mysqli_fetch_array($q); 
?>

输出数据:

   <h1>
       <?php   
       echo $row['SongName'];
       ?>
   </h1>
   <p> 
     <?php 
        echo '<b>', 'By: ', '</b>'. $row['ArtistsName'] . ' ft. ' . 
        $row['Features'] . '</br>';
        echo '<i>' . $row['Album'] . '</br>', '</br>', '</i>';
        echo '<b>', 'Genre: ', '</b>' . $row['Genre'] . '</br>', '</br>';
        echo '<b>', 'Rating: ', '</b>' . $row['Rating'] . '/5', '</br>', 
        '</br>';
        echo '<b>', 'Comments: ', '</b>', '</br>', '</br>' . 
        $row['Comments'];
      ?>    
   </p>

当回显$ file时,它显示名称为form_130.php,而在我的链接表中的链接表中的数据库中显示值form_130.php

0 个答案:

没有答案