I need some guidance with my delete function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
RudyRodney
Forum Newbie
Posts: 7
Joined: Mon Nov 02, 2009 8:59 pm

I need some guidance with my delete function

Post by RudyRodney »

I have a site that has user profiles. A user can comment on a another users profile. I have this all set up. What I am trying to do now, is through PHP, make a delete link appear ONLY when a users is looking at their own profile, and disappear when they are looking at other peoples profiles.

So I can not figure out how to:

1. make the delete link reload the page with the chosen comment to be deleted actually deleted

2. tell the db to mark the deleted comment as 'dead'

3. make the delete link only appear on YOUR profile and not when you are looking at other people profiles.


Not trying to get people to do this for me, I have been researching this for 12 hours today and can not make it happen

Any links to resources, examples etc... would be greatly appreciated

:banghead:
RudyRodney
Forum Newbie
Posts: 7
Joined: Mon Nov 02, 2009 8:59 pm

Re: I need some guidance with my delete function

Post by RudyRodney »

btw...I've got this all in a while loop, so besides making a proper query, I'm kinda thinking that I might need to insert an if statement in my while loop, and also confused on how if I need to make a second query under the query that is for the posting of the comments, or add on to it
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: I need some guidance with my delete function

Post by John Cartwright »

It seems everybody today is expecting us to be mind readers! Seriously, we need to see the relevant code to be of any assistance (with examples of what you have tried).
RudyRodney
Forum Newbie
Posts: 7
Joined: Mon Nov 02, 2009 8:59 pm

Re: I need some guidance with my delete function

Post by RudyRodney »

I don't see how what I am asking is not clear? The code in question does not exist...I am looking for some guidance or examples of code that would do what I said I wanted to do.

thanks
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: I need some guidance with my delete function

Post by John Cartwright »

You need to show us the house frame before we can recommend on how to brick it..

Sure, I can give you example on how it can be done, but surely it is not in the same context (therefore, wasting both our time).

So please, show the relevant code if you want assistance.
RudyRodney
Forum Newbie
Posts: 7
Joined: Mon Nov 02, 2009 8:59 pm

Re: I need some guidance with my delete function

Post by RudyRodney »

Gotcha, here is the the query and while loop that is holding the comments.


<?php

$query = "SELECT * FROM `profileComments` WHERE `ToUserID` = '".$prof->id."' ORDER BY `date` DESC, `time` DESC LIMIT 10";


$request = mysql_query($query,$connection);


while($result = mysql_fetch_array($request)) {





$poster = new User($result['FromUserID']);

echo "<div id='CommentProfile'>";
echo "<div id='CommentPhotoProfile'>";
echo "<a href='http://www.blahblahblah.org/Profile.php ... poster->id."'>";
echo "<img src='" . $poster->img('mini') . "' border='0'/>";
echo "</a>";
echo "</div>";
echo "<div id='ProfileCommentBody' class= 'round_10px'>";
echo "<div id='CommentNameProfile'>";
echo "<div class='ProfileCommentTail'>&nbsp;</div>";
echo "<a href='http://www.blahblahblah.org/Profile.php ... poster->id."'>";
echo $poster->first_name. " ". $poster->last_name. " <span style='font-weight:normal'>says...</span>";
echo "</a>";
echo "</div>";
echo stripslashes(nl2br($result['commentProfileBody']));
echo "<div id='CommentInfoProfile'>";
echo date('M d, Y',strtotime($result['date']));
echo " at " . date('g:i A',strtotime($result['time']));

/* assuming this is where I would put the if statement?
and please also note that DeleteComment.php exist, but I would rather not use it, right now it is a link to a page that confirms your comment has been deleted. I would rather the page reload with the comment deleted, as well as send the message marked as dead to the db*/


echo "<a href='http://www.blahblahblah.org/DeleteComme ... .$prof->id."'>";
echo " delete";
echo "</a>";
echo "</div>";
echo "</div>";
echo "</div>";
}

?>
Post Reply