i'm trying away:
<?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>"; ?> but when click link refresh page, instead of redirects variable element (), added in db mysql , exposed @ home, clicking on link direct page of details of specific element working, not targeting properly.
function get_posts($id = null, $cat_id = null){ $posts = array(); $query = "select `posts`.`id` `post_id` , `categories`.`id` `category_id`, `title`,`endereco`,`cidade`,`email`,`telefone`,`categories`.`name` `posts` inner join `categories` on `categories`.`id` = `posts`.`cat_id` " ; if(isset($id)){ $id = (int)$id; $query .= " `posts`.`id` = {$id} "; } if(isset($cat_id)){ $cat_id = (int)$cat_id; $query .= " `cat_id` = {$cat_id} "; } $query .= "order `post_id` desc"; $query = mysql_query($query); while($row = mysql_fetch_assoc($query)){ $posts[] = $row; } return $posts; }
in php:
$link = 'index.php?id='.$row['post_id']; print '<span class="survey-name"><a href="'.$link.'">'.$row['title'].'</span>'; note: guess ['post_id'] $row['post_id'] because ['post_id'] nothing.
Comments
Post a Comment