473,240 Members | 1,589 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,240 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 1394
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
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
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...

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.