473,320 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Display delete link near comments for that logged in users

I have a page which shows the comments posted by all users. Here I need to show a delete link on the side of the comments posted by that current logged in user and he should be able to delete that comment too (like in Facebook, Orkut or any Blogging site). The sample code which I have tried is:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $user_id = 1;
  3. $con = mysql_connect("localhost","root","root");
  4. if (!$con)
  5.   {
  6.   die('Could not connect: ' . mysql_error());
  7.   }
  8.  
  9. mysql_select_db("blog", $con);
  10.  
  11. $result = mysql_query("SELECT * FROM replies");
  12.  
  13. while($row = mysql_fetch_array($result))
  14.   {
  15.   $replies = $row;
  16.   if($replies['poster_id' == $user_id]){
  17.       $delete = '<a href="#">Delete</a>';
  18.   }
  19.  
  20.   echo $replies['poster_id']?></a>&nbsp;¦&nbsp;<?php echo $replies['reply_text']?>&nbsp;¦&nbsp;  <?php echo $delete?></div>
  21.  
  22.   <?php echo "<br />";
  23.   }
  24.  
  25. mysql_close($con);
  26. ?> 
  27.  
Here I have given the user_id which is hardcoded here. What I got is, delete link is displayed on all comments. I need to display delete link for user_id with "1" only. Can anyone suggest me to get the solution...Thanks in Advance...
May 1 '11 #1
1 1395
johny10151981
1,059 1GB
try this
Expand|Select|Wrap|Line Numbers
  1. <a href='javascript:createDeleteRequest("<?=$replies['poster_id']?>")'>[&nbsp;Delete&nbsp;]</a>
  2.  
createDeleteRequest make this function to create delete request using ajax. after ajax return successful reply hide the row that displays text

after process success
May 1 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: raj | last post by:
how do i display primary keys, foreign keys that a table has.
0
by: ActiveUp | last post by:
http://www.activeup.com/products/components/activecalendar Active Calendar is an ASP.NET server control that allows users to select a date and/or time quickly using a professional looking date...
1
by: Marcin Zmyslowski | last post by:
Hello all! I want to create a page in ASP language which gives me information about currently logged users. I thought to do it by this way: when somebody will log in to page, there will be a...
1
by: Lester3 | last post by:
i'm looking for a script that will allow me to display a link which when clicked is replaced by an image. Its for one of my discography pages where i don't want all the images displayed when the...
2
by: Rick Ng Chi Wah | last post by:
Dear all, I have a text file call access.log and it contains about 5030 lines. Some lines contain some keyword, e.g. "ricky ng". How can I delete all the entries that contain "ricky ng" line and...
1
by: George W. Barrowcliff | last post by:
I'd like to display a trail of links showing the user the links they used to get to the current page. This is getting more and more common and I searched for javascripts but did not get any hits....
0
by: AJAY SHARMA | last post by:
rpasken@eas.slu.edu , You have made comments that Momentum is not Conserved in my PAPER. It is not CORRECT. It is explained in 100 Years of E=mc2 rpasken@eas.slu.edu Robert Pasken ...
3
by: sudhashekhar30 | last post by:
HI all I am using gridview. i have added a column "delete" in gridview through wizard. i want to delete record on the click of respective delete link. ------------inline code--------- ...
13
by: snowinfo | last post by:
Hi all, any way to count the number of users i have logged into my site? any help/code appreciated, craig
1
by: zy413952631 | last post by:
list the number of times each user is logged on Thank you for your kind concern
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.