我正在试着这个:
<?php
$link = "'index.php?id=echo ['post_id']; "
?>
<?php
while ($row = mysql_fetch_array($result)) {
echo "<span class='survey-name'><a href='$link'>". $row['title'] ."</span>";
?>
但是当我点击链接它只是刷新页面,而不是重定向到变量元素(),它在DB mysql中添加并在家中公开,但点击这样的链接将指向详细信息的页面这个特定元素已经有效,只是没有正确定位。
function get_posts($id = null, $cat_id = null){
$posts = array();
$query = "SELECT `posts`.`id` AS `post_id` , `categories`.`id` AS `category_id`, `title`,`endereco`,`cidade`,`email`,`telefone`,`categories`.`name` FROM `posts` INNER JOIN `categories` ON `categories`.`id` = `posts`.`cat_id` " ;
if(isset($id)){
$id = (int)$id;
$query .= " WHERE `posts`.`id` = {$id} ";
}
if(isset($cat_id)){
$cat_id = (int)$cat_id;
$query .= " WHERE `cat_id` = {$cat_id} ";
}
$query .= "ORDER BY `post_id` DESC";
$query = mysql_query($query);
while($row = mysql_fetch_assoc($query)){
$posts[] = $row;
}
return $posts;
}
答案 0 :(得分:3)
:
$link = 'index.php?id='.$row['post_id'];
print '<span class="survey-name"><a href="'.$link.'">'.$row['title'].'</span>';
注意:我猜['post_id']
是$row['post_id']
,因为['post_id']
不算什么。