我有我需要在我的php用戶帖子中引用的javascript,但我需要顯示行信息,如下所示。我不知道是否需要將這個JavaScript放在我的PHP中,而我需要回顯行或者類似的東西。我使用這個參考javascript:在javascript中顯示一個mysql行
<a id='popoverId' class='popoverThis'>Something here</a>
所以我不知道究竟該做什麼。
<script type="text/javascript">
$(document).ready(function() {
$('#popoverId').popover({
html: true,
title: '<img src="<?php echo ". $row['cpic'] . "; ?>" height="80px"><h4><a href="/profile?id=2"><img src="/uploads/2/ppic.jpg" height="50px" style="border-top:white 4px solid;"> Wyatt Abraham</a></h4>',
});
$('#popoverId').click(function (e) {
e.stopPropagation();
});
$(document).click(function (e) {
if (($('.popover').has(e.target).length == 0) || $(e.target).is('.close')) {
$('#popoverId').popover('hide');
}
});
});
</script>
我知道,我上面所做的是遙遠,但任何幫助是巨大的:)
編輯(究竟是什麼我的代碼看起來像在這一點上):
<script type="text/javascript">
$(document).ready(function() {
$('#popoverId').popover({
html: true,
title: '<img src="<?php echo $row['ppic']; ?>" height="80px"><h4><a href="/profile?id=2"><img src="/uploads/2/ppic.jpg" height="50px" style="border-top:white 4px solid;"> Wyatt Abraham</a></h4>',
});
$('#popoverId').click(function (e) {
e.stopPropagation();
});
$(document).click(function (e) {
if (($('.popover').has(e.target).length == 0) || $(e.target).is('.close')) {
$('#popoverId').popover('hide');
}
});
});
</script>
<?php
mysql_select_db("*");
$result = mysql_query("SELECT * FROM posts ORDER BY id DESC");
echo "<table border='0'>
<tr>
<th></th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<div class='container'>
<div class='bordered'>
<div class='posts'>";
echo "<img class src='" . $row['ppic'] . "' width='60px'>";
//. $row['name'] ." ".$row['post'] ."";
echo " ";
echo "<a href='/profile.php?id=". $row['userid'] ."'> " . $row['name'] . "";
echo "</a><hr />";
echo "<a id='popoverId' class='popoverThis'>Something here</a>";
echo "<p class='padding'> " . $row['post'] . "";
echo "</p>";
echo "<div class='foot'>
<a href='#' class='vbutton'><span class='glyphicon glyphicon-thumbs-up'></span> Like It!</a><a href='#' class='vbutton'><span class='glyphicon glyphicon-thumbs-down'></span> Dislike It!</a>";
echo "</div>
</div>
</div>
</div>";
}
?>
你面臨什麼錯誤? – Manwal
基本上我試圖引用的圖片沒有顯示。 – Saffron
img src標籤中的url是什麼?可能是有錯誤的網址 – Manwal