SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: query help

  1. #1
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    query help

    i have a code here

    Code:
    $query = "SELECT DATE_FORMAT(commentdate, '%M %D, %Y - %l:%i %p'), username, comment, commentID FROM 
    		comments WHERE postID='$id' ORDER BY commentdate DESC";
    		$result = @mysql_query($query) or die(mysql_error());
    		$num = mysql_num_rows($result);
    		
    		if ($num > 0)
    		{
    			$uname = $_SESSION['firstname'];
    			//report edit
    			$editquery = "SELECT postID, username, commentID FROM comments 
    			WHERE postID='$id' AND username='$uname'";
        		$editresult = @mysql_query($editquery) or die(mysql_error());    
        		if ($row = mysql_fetch_assoc($editresult))
        		{
    				$edit = '<a href="reportcommentedit.php?eid='.$_GET['pid'].'&cid='.$row['commentID'].'" class=under>EDIT</a>';
        		}
        		else
       			{
            		$edit = '&nbsp;';
        		}
    this is to get both the eid and the cid from here to another page...it works...but the problem is that when there are 2 or more edit link, their cid is the same....so when i edit the the last comment, the it is changing the first comment, and not the current comment....i know there's something wrong about my query...can you help me guys?

    thanks

  2. #2
    SitePoint Enthusiast Bobbi's Avatar
    Join Date
    Mar 2005
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $editquery "SELECT postID, username, commentID FROM comments WHERE postID='$id' AND username='$uname'"
    This query always returns the same results, as $id and $uname will never change ... so $row['commentID'] will contain the same ID all the time as well.

    From the look of it, there're lots of unnecessary code in that anyway, but I don't know your script well enough to know what you're actually doing there

    Bobbi


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •