-1
我的目標是打開具有模式ID的循環$ viewhh中鏈接的詳細信息。我已經通過jQuery等嘗試了很多不同的方法,並且無法獲得任何工作。只是調用頁面正常工作,但嘗試加載模式對我來說是徒勞的。將變量傳遞給jquery
<div class="row">
<div class="col-md-12">
<p><a class="btn btn-default" href="add_praise.php" role="button">Add a Praise</a></p>
<h2>Praises</h2>
<p><?php
$query = "SELECT praise.id, praise.title, praise.description, praise.created, member.username FROM praise INNER JOIN member ON praise.member_id=member.id ORDER BY praise.created desc;";
$stmt = $db->query($query);
printf('<table class="table">');
printf('<thead><tr><th>Title</th><th>Posted By</th><th>Posted</th></tr></thead>');
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$created = date('m-d-Y', strtotime($row['created']));
$viewhh = '<a href="view_praise.php?id=' .
urlencode($row["id"]) . '">' . ($row["title"]) . '</a>';
printf("<tbody><tr><td> %s </td> <td> %s </td><td> %s </td><td> %s </td></tr></tbody>", $viewhh, htmlentities($row["username"]), $created, $viewbutton);
printf("</table");
}
?> </p>
</div>
這是被稱爲
<?php
$praiseid = urldecode($_GET['id']);
$sth = $db->prepare("select * from praise where id = '$praiseid'");
$sth->execute();
$result = $sth->fetch(PDO::FETCH_ASSOC);
$title = $result['title'];
$description= $result['description'];
?>
<div class="container">
<!-- Example row of columns -->
<div class="row">
<div class="col-md-4">
<h2><?php echo $title; ?></h2>
<div><?php echo $description; ?></div>
</div>
</div>
頁我曾嘗試加入這個,但現在只得到了第一個記錄。
<script>
$(function() {
$("#loadpraise").colorbox({ iframe: true, width: "90%", height: "90%", closeButton: false });
$("#events").colorbox({
onOpen: function() { alert("Colorbox onOpen"); },
onLoad: function() { alert("Colorbox onLoad"); },
onComplete: function() { alert("Colorbox onComplete"); },
onCleanup: function() { alert("Colorbox onCleanup"); },
onClosed: function() { alert("Colorbox onClosed"); }
});
$("#childForm").colorbox({ closeButton: false, onClosed: function() { alert($.colorbox.popupResult) } });
});
</script>
有什麼具體問題? – 2014-10-07 19:50:16
哪裏是js代碼? – shampoo 2014-10-07 19:56:10
這看起來[恐怖不安全](http://bobby-tables.com/)。你確定**你的用戶參數是[妥善轉義](http://bobby-tables.com/php)?使用PDO時,請務必使用[預準備語句](http://php.net/manual/en/pdo.prepared-statements.php)以避免手動轉義或處理引用問題。 – tadman 2014-10-07 20:23:08