php - Show delete link on comments -
i have page shows comments posted users. here need show delete link on side of comments posted current logged in user , should able delete comment (like in facebook, orkut or blogging site). sample code have tried is:
<?php $user_id = 1; $con = mysql_connect("localhost","root","root"); if (!$con) { die('could not connect: ' . mysql_error()); } mysql_select_db("blog", $con); $result = mysql_query("select * replies"); while($row = mysql_fetch_array($result)) { $replies = $row; if($replies['poster_id' == $user_id]){ $delete = '<a href="#">delete</a>'; } echo $replies['poster_id']?></a> ¦ <?php echo $replies['reply_text']?> ¦ <?php echo $delete?></div> <?php echo "<br />"; } mysql_close($con); ?>
here have given user_id hardcoded here. got is, delete link displayed on comments. need display delete link user_id "1" only. can suggest me solution...thanks in advance...
if($replies['poster_id' == $user_id]){
need be
$delete =''; if($replies['poster_id'] == $user_id){ $delete = '<a href="#">delete</a>'; }
you need unset $delete
variable in every loop, if not once value , present in every cycle of loop
Comments
Post a Comment