Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/417.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javascript中的Php_Javascript_Php_Jquery_Html_Mysql - Fatal编程技术网

javascript中的Php

javascript中的Php,javascript,php,jquery,html,mysql,Javascript,Php,Jquery,Html,Mysql,我有很多dvd,所以我想我会尝试创建一个mysql数据库并将其输出到php站点上 这是我第一次接触到这两个问题,我很乐意接受一些建设性的批评。我知道代码有点凌乱,有些是这样,我可以在学习的同时更好地阅读它 我正在使用Xampp运行这些 我的第一个输出工作正常,它将结果显示在表DVD id、封面、名称、Genra、预告片中。 这是这个的文件。 (没有足够的声誉发布链接1) 现在我要做的是把标题下的图片并排放在一起。这本身就是我想要的。(没有足够的声誉发布链接2) 当我点击显示dvd信息的封面时,我

我有很多dvd,所以我想我会尝试创建一个mysql数据库并将其输出到php站点上

这是我第一次接触到这两个问题,我很乐意接受一些建设性的批评。我知道代码有点凌乱,有些是这样,我可以在学习的同时更好地阅读它

我正在使用Xampp运行这些

我的第一个输出工作正常,它将结果显示在表DVD id、封面、名称、Genra、预告片中。 这是这个的文件。 (没有足够的声誉发布链接1)

现在我要做的是把标题下的图片并排放在一起。这本身就是我想要的。(没有足够的声誉发布链接2)

当我点击显示dvd信息的封面时,我想要的是一个弹出窗口,例如简介、类型和dvd id

这个网站有帮助 我不能让它在网站内工作,不知道如何排序

这不起作用,我想这是因为我在div中更改了div名称使其唯一,但无法使脚本工作

    <!doctype html>

<html>
       <head>
           <meta http-equiv = ".content-type." content=".text/html; charset=utf-8." />
           <title>Video Database Output</title>
           <meta name="Description" content="Video Database" />
           <link href="style2.css" rel="stylesheet" type="text/css" />
            <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
            <script src="jquery.popupoverlay.js"></script>


       </head>
               <body>
<div id = "wrapper">
<Div id = "headder"> <h1> Video Database</h1></div>
<div id = "content">


<?php

$hostname = "localhost"; 
$username="acess";
$password="123456";
$database="video_database";



//connection to the database

mysql_connect($hostname, $username, $password) 
  or die("Unable to connect to MySQL");



@mysql_select_db($database) or die( "Unable to select database");

$query="SELECT * FROM video";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();


//display results






$i=0;
while ($i < $num) {

$dvd_id=mysql_result($result,$i,"dvd_id");
$film_tv=mysql_result($result,$i,"film_tv");
$format=mysql_result($result,$i,"format");
$genre=mysql_result($result,$i,"genre");
$genre_2=mysql_result($result,$i,"genre_2");
$genre_3=mysql_result($result,$i,"genre_3");
$name=mysql_result($result,$i,"name");
$trailer=mysql_result($result,$i,"trailer");
$id=mysql_result($result,$i,"id");
$description=mysql_result($result,$i,"description");
$cover=mysql_result($result,$i,"cover");

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



 echo "
 <div id=\"my_popup".$id."\">

    <table>
    <tr>
    <td> $genre</td> <td>$genre_2</td> <td>$genre_3</td>
    </tr>
    </table>

    <!-- Add an optional button to close the popup 
    <button class=\"my_popup_close\">Close</button>-->

  </div>
";







 echo "
  <table>

  ";


if ($cover!="")
{
echo "
    <tr>
        <td>
            <img class = \"cover\" src = ". $cover ." alt = \" cover\" >
        </td>
    </tr>
    <tr>
        <td>
            $name
        </td>
    </tr>   
";
}
else  
{
echo "
    <tr>
        <td>
            <img class = \"cover\" src = \" covers\blank.jpg \" alt = \" cover\" >
        </td>
    </tr>
    <tr>
        <td>
            $name
        </td>
    </tr>   
";
}

echo " <button class=\"my_popup".$id."\">Open popup</button> </table></div>";

  <script>
    $(document).ready(function() {

      // Initialize the plugin
    <?php echo " $(\'#my_popup$id\').popup();  ";?>

    });
  </script>


$i++;



}


?>




</div>

</div>
<div id = "footer"><p> t </p></div>
</body>
</html>

视频数据库输出
视频数据库
t

我试图用搜索引擎找到答案,但找不到合适的答案。
感谢您的帮助

将JS语句置于PHP之外:

<script>
    $(document).ready(function() {
        // Initialize the plugin
        $('#my_popup<?php echo $id; ?>').popup();
    });
</script>

$(文档).ready(函数(){
//初始化插件
$('my#u popup').popup();
});

(1)(2)尝试使用HTML生成HTML内容,而不是PHP中的
echo
。使用
echo
生成PHP变量,使代码更简单、更美观。