javascript - 在 php 中调用一个函数

标签 javascript mysql wordpress php

<分区>

可能是一个菜鸟问题,但可以通过提问来学习。

我正在尝试建立一个表来从我的数据库中加载和显示数据。除了最后一列,我已经完成了所有工作。我希望最后一列是一个显示“查看图像”的链接,当您单击它时,它会打开一个 fancybox JS。

这是我的源代码:

    <script>
$(document).ready(function() {
    $(".fancybox-thumb").fancybox({
        prevEffect  : 'none',
        nextEffect  : 'none',
        helpers : {
            title   : {
                type: 'outside'
            },
            thumbs  : {
                width   : 50,
                height  : 50
            }
        }
    });
});
</script>


<?php




mysql_select_db("premiumguns") or die(mysql_error());


echo "<table id='myTable' class='info' width='100%' border='0' cellspacing='0' cellpadding='0'>";
echo "<thead><tr> <th>Serial</th> <th>Make</th> <th>Model</th> <th>Gauge</th> <th>Barrel</th> <th>Details</th></tr></thead><tbody>";

// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {


    // Print out the contents of each row into a table

    echo "<tr><td height=\"20px\">"; 
    echo $row['Serial_No'];
    echo "</td><td>"; 
    echo $row['Make'];
    echo "</td><td>"; 
    echo $row['Model'];
    echo "</td><td>"; 
    echo $row['Gauge'];
    echo "</td><td>"; 
    echo $row['Barrel_Length'];
    echo "</td><td>";
    echo "<a class = "fancybox-thumb" rel="gallery1" href="wp-content/prem_pics/C16719B/C16719B-01.jpg">View Pictures</a>"
    echo "</td></tr>"; 
} 

echo "</tbody></table>";
?>
</body>

任何帮助将不胜感激

最佳答案

你需要在这一行周围使用单引号

<?php
    echo '<a class = "fancybox-thumb" rel="gallery1" href="wp-content/prem_pics/C16719B/C16719B-01.jpg">View Pictures</a>';
?>

关于javascript - 在 php 中调用一个函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17868523/

相关文章:

c# - 带有javascript确认功能的必填字段验证器未验证

javascript - 如果 p 元素在它之前,JQuery 不会隐藏 div?

javascript - 无法获取属性值 'elementType' : object is null or undefined

mysql - 如何在mysql中将字符串格式化为时间?

php - 如何使 laravel 多对一(hasMany)关系有效

javascript - 根据数据类型总结编辑框列表?

php - 选择所有行,除非此条件为真

html - 使用@media 对齐 div

MySql 到 Wordpress 查询

javascript - 用 VueJS 2.0 模拟 Pjax