Page 1 of 1

additional id?

Posted: Tue Mar 22, 2005 4:32 am
by pleigh
can i add another id from this code?

Code: Select all

$edit = '<a href="reportcommentedit.php?cid='.$_GET['pid'].'" class=under>EDIT</a>';
i would like to add eid(for edit id) after or before the cid....is this possible??i would like to declare eid and cid and use GET method to another page...

Posted: Tue Mar 22, 2005 4:41 am
by Pyrite

Code: Select all

$edit = '<a href="reportcommentedit.php?cid='.$_GET['pid'].'&eid='.$_GET['eid'].'" class=under>EDIT</a>';
??

Posted: Tue Mar 22, 2005 4:49 am
by pleigh
nope, got a parse error when i did this

Code: Select all

$edit = '<a href="reportcommentedit.php?eid='.$_GET['pid'].'&cid='$_GET['eid']'" class=under>EDIT</a>';
some more advises?

Posted: Tue Mar 22, 2005 4:58 am
by n00b Saibot

Code: Select all

$edit = '<a href="reportcommentedit.php?cid='.$_GET['pid'].'&eid='.$_GET['eid'].'" class=under>EDIT</a>';
Remember the above code will give error if $_GET['eid'] doesn't exist.
So you have to take care of that. :wink:

Posted: Tue Mar 22, 2005 5:05 am
by pleigh
thanks to you guys...but another problem occur....i changed the query for the commentID

Code: Select all

$editquery = "SELECT postID, username, commentID FROM comments WHERE postID='$id' AND username='$uname'";
    		$editresult = @mysql_query($editquery) or die(mysql_error());    
    		if (mysql_fetch_assoc($editresult))
    		{
        //		$edit = '<a href="reportcommentedit.php?cid='.$_GET['pid'].'" class=under>EDIT</a>';
				$edit = '<a href="reportcommentedit.php?eid='.$_GET['pid'].'&cid='.$row[3].'" class=under>EDIT</a>';
    		}
    		else
   			{
        		$edit = '&nbsp;';
    		}
when i try to point the cursor to the edit link, eid is getting its value from another table....from the posts table...and not from $row[2] which is the commentID from comments table...

Posted: Tue Mar 22, 2005 5:09 am
by Pyrite
Should that be if ($row = mysql_fetch_assoc($editresult)) ??

Posted: Tue Mar 22, 2005 5:29 am
by pleigh
did this now

Code: Select all

$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;';
    		}
it worked but there is a problem...when pointing over the edit link....the value of cid is the same as the other edit links....for example....i have 3 links, 1 of the comments has an id (cid=7)..the cid of the other 2 id is the same(cid=7)...when i tried to update it, that one with the cid=7 is the only comment that is updated, even if its the other comments i am editing....

Posted: Tue Mar 22, 2005 4:58 pm
by John Cartwright
are you trying to return multiple rows?

if so you will have to use a loop: http://php.net/while

Posted: Tue Mar 22, 2005 5:26 pm
by Pyrite
Just don't restrict your query to the postid, but only the username, then get all the comments by username but getting their postid's for each one. make sense?