PHP代码(mysqli)查询在特定代码后不工作 [英] PHP code (mysqli) queries are not working after specific code

查看:107
本文介绍了PHP代码(mysqli)查询在特定代码后不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有PHP代码,我们可以调用此代码BLOCKONE:

I have PHP code we can call this code BLOCKONE:

$maker = "SELECT vidMaker FROM videoinformation";
if ($result = mysqli_query($con, $maker)) {
    while ($row = mysqli_fetch_row($result)) {
        $values = explode(',',$row[0]);
        foreach($values as $v)
        if (!empty($v)) {
           printf ("<img class=\"makerImg\" src=\"addVid/maker/%s.jpg\">", $v);
        }
    }
    mysqli_free_result($result);

}
else{
    echo"PM administrator with an error";
}

我有大的PHP代码,如:

I have big PHP code like:

    <!DOCTYPE html>
    <head>
    </head>

    <body>
    <?php>
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    BLOCKONE
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    ?>
    </body>

</html>

问题是 BEFORE BLOCKONE所有的mysqli查询都在工作,显示信息,图片等,但 AFTER BLOCKONE没有任何查询正在工作。



为什么我知道这个代码中的问题?因为如果删除它...全代码工作正常。

The question is BEFORE BLOCKONE all the mysqli queries are working, I can display information, images and so on, but AFTER BLOCKONE none of the queries are working.

Why I know that the problem exactly in this code? Because if delete it... full code working fine. And I'm not sure hot to solve it.

这是完整的代码:

<!DOCTYPE html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<?php include 'BSH.php' ?>
<link rel="stylesheet" type="text/css" href="CSS/ldvid.css">
<script type="text/javascript" src="java/FWDUVPlayer.js"></script>

        <!-- Setup video player-->
        <script type="text/javascript">
        <?php include 'video/settings.php'; ?>
        </script>

</head>
<body>


<?php include_once 'userPages/check_login_status.php';?>
<?php include_once 'incIndex/headerTop.php'; ?>
<?php include_once 'incIndex/footer.php'; ?>

<?php

// here we get the incomming video id (videoinfo.php?id=123)
$video_id = $_GET['id'];

// build a database query to select the videoInformation
// here we use WHERE to select the video_id we want
$query = 'SELECT newsvid.id, videoinformation.id, videomain.id, newsvid.vidTitle, newsvid.imgCover, videoinformation.vidLD, videoinformation.vidYear, videoinformation.vidCity, videoinformation.vidZanr, videoinformation.vidZanr2,videoinformation.vidZanr3,videoinformation.vidQuality, videoinformation.vidTranslated, videoinformation.vidMaker, videoinformation.vidRoles, videoinformation.vidTime, videoinformation.imgShot1, videoinformation.imgShot2, videoinformation.imgShot3, videomain.vidMUrl FROM newsvid, videomain, videoinformation WHERE newsvid.id = videoinformation.id AND newsvid.id = videomain.id AND newsvid.id = '. $video_id ;

// lets connect and do the query
include 'connect/con.php';
$result = mysqli_query($con, $query);


echo "<div class=\"ldCover\">"; 

while($row = mysqli_fetch_array($result)) {

echo "<div class=\"panel panel-default\"><div class=\"panel-heading\">";
echo "<div><strong><h3>" . $row['id']. " | " . $row['vidTitle'] . "</h3></strong></div>";

echo "</div><div class=\"panel-body\">";
echo "<div class=\"imgCover\"><img style=\"width:200; height:320px\" class=\"img-thumbnail\"src=\"upload/videoCover/" . $row['imgCover'] . "\"></div>";
echo "<div class=\"vidLD\">
<table>
<tr><td class=\"tdBR\"><strong> Years: </strong></td><td >" . $row['vidYear'] . "</td></tr>
<tr><td class=\"tdBR\"><strong> City: </strong></td><td >". $row['vidCity'] . "</td></tr>
<tr><td class=\"tdBR\"><strong> Zanr: </strong></td><td >". $row['vidZanr'] ." , ". $row['vidZanr2'] ." , ". $row['vidZanr3'] . "</td></tr>
<tr><td class=\"tdBR\"><strong> Quality: </strong></td><td >". $row['vidQuality'] . "</td></tr>
<tr><td class=\"tdBR\"><strong> Translated: </strong></td><td >". $row['vidTranslated'] . "</td></tr>
<tr><td class=\"tdBR\"><strong> Video time: </strong></td><td >". $row['vidTime'] .  "</td></tr>

</table>" . $row['vidLD'] . "</div></div>";


 echo "<div class=\"panel-body\" style=\"border-top: 1px solid; border-bottom: 1px solid; border-color:#ddd\"><div class=\"vidDesc\">
 </div>";


 echo "<div class=\"vidMR\">
<div><strong> Maker: </strong>" . $row['vidMaker'] . "</div><div>";

$maker = "SELECT vidMaker FROM videoinformation WHERE id=".$row['id'];
if ($result = mysqli_query($con, $maker)) {
    while ($row = mysqli_fetch_row($result)) {
        $values = explode(',',$row[0]);
        foreach($values as $v)
        if (!empty($v)) {
           printf ("<img class=\"makerImg img-circle\" src=\"addVid/maker/%s.jpg\">", $v);
        }
    }
    mysqli_free_result($result);

}
else{
    echo"PM administrator with an error";
}

echo"</div><div><strong> Roles: </strong>". $row['vidRoles'] . "</div>
<div><table>";
$role = "SELECT vidRoles FROM videoinformation WHERE id=".$row['id'];
if ($result = mysqli_query($con, $role)) {
    while ($row = mysqli_fetch_row($result)) {
        $values = explode(',',$row[0]);
        foreach($values as $v)
        if (!empty($v)) {
           printf ("<img class=\"roleImg img-circle\" src=\"addVid/roles/%s.jpg\">", $v);
        }
    }
    mysqli_free_result($result);

}
else{
    echo"PM administrator with an error";
}
echo "</table></div></div></div>";

echo"<div class=\"panel-body\"><div class=\"screenshots\">";
 echo "<div class=\"imgShot1\"><img style=\"width:245px; height:140px\" class=\"img-thumbnail\" src=\"upload/" . $row['imgShot1'] . "\"></div>";
 echo "<div class=\"imgShot2\"><img style=\"width:245px; height:140px\" class=\"img-thumbnail\" src=\"upload/" . $row['imgShot2'] . "\"></div>";
 echo "<div class=\"imgShot3\"><img style=\"width:245px; height:140px\" class=\"img-thumbnail\" src=\"upload/" . $row['imgShot3'] . "\"></div>";
echo"</div>";


echo "</div><div class=\"panel-footer\">";
echo "<div class=\"vidMUrl\"> 

 <div id=\"myDiv\"></div>

<ul id=\"playlists\" style=\"display:none;\">
<li data-source=\"playlist1\" data-playlist-name=\"MY HTML PLAYLIST\" data-thumbnail-path=\"content/thumbnails/large1.jpg\">
</li></ul>

<ul id=\"playlist1\" style=\"display:none;\">
<li data-thumb-source=\"content/thumbnails/small-fwd.jpg\" data-video-source=\"". $row['vidMUrl'] . "\" data-poster-source=\"upload/videoCover/" . $row['imgCover'] . "\" data-downloadable=\"yes\">
</li></ul>

 </div>";


echo "</div></div></div>";
}
mysqli_close($con);

?>








</body>
</html>


推荐答案

您假设获得多行,您总是重写:

You are assuming to get more than one row, but you are always rewriting that:

while ($row = mysqli_fetch_array($result)) {

在你的主循环中,你总是重写你的 $ result 和<$ c

In your main loop, you are always rewrite your $result and $row variable.

在while循环中,使用 $ result2 $ row2

Inside the while loop, use $result2, and $row2.

这篇关于PHP代码(mysqli)查询在特定代码后不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆