-2
我不知道是否有可能,但我必須分配「按鈕」「id =」查詢值。像:更改元素屬性值與查詢值
<button type="button" class="prevbutton" id="1">Previous</button>
<button type="button" class="nextbutton">Next</button>
<?php
$poffset = 0;
if ($d > '2016-01-01') { $whereday = "AND n.timestamp >= '$d 00:00:00' AND n.timestamp < '$d 23:59:59'"; $limit = ""; } else { $limit = "LIMIT $poffset,9"; }
$term = str_replace('-', ' ', $term);
if ($term !== '') { $whereaterm = "AND (n.news_title LIKE '%$term%' OR n.news_article LIKE '%$term%')"; $limit = "LIMIT 8,9"; }
$abfrage59 = "SELECT n.news_title,n.news_id as newsId,FLOOR(TIMESTAMPDIFF(HOUR, n.timestamp, NOW())) as diff
FROM news n
WHERE n.domain_id = '2' AND n.timestamp < NOW() $whereday $whereaterm
ORDER BY timestamp DESC
$limit";
$ergebnis59 = mysql_query($abfrage59);
while ($row59 = mysql_fetch_object($ergebnis59)) {
$newstitleslug = $row59->news_title;
$newstitleslug = str_replace(' ', '-', $newstitleslug);
$newstitleslug = strtolower($newstitleslug);
?><script>$(".prevbutton").attr("id", "$row59->newsId");</script><?php
echo "<div class=\"col-sm-6 col-md-4\" style=\"padding-bottom: 15px;\">
<div class=\"item\">
<img class=\"main\" src=\"http://lolcahost/images/news/$row59->news_id.png\" />
<div class=\"text\">
<div class=\"inner\">
<a href=\"http://localhost/news-article/$newstitleslug/$row59->news_id/\" style=\"color:white;\">$row59->news_title<br />
<span class=\"date\">$row59->diff hours ago</span>
</div>
</div>
</div>
</div>";
}
?>
所以我用這個php內部查詢,但id獲取值「$ row59-> newsId」,而不是查詢值。有任何想法嗎?提前致謝。
?><script>$(".prevbutton").attr("id", "$row59->newsId");</script><?php
Shoudn't'<='表示適當爲'
@ RokoC.Buljan如果我理解正確,兩種選擇都可以接受。 '<?php echo $ a;?>''=$a;?>' – jekaby
非常感謝。它有幫助。 –