additional id?

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
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

additional id?

Post 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...
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post by Pyrite »

Code: Select all

$edit = '<a href="reportcommentedit.php?cid='.$_GET['pid'].'&eid='.$_GET['eid'].'" class=under>EDIT</a>';
??
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post 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?
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post 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:
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post 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...
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post by Pyrite »

Should that be if ($row = mysql_fetch_assoc($editresult)) ??
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post 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....
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

are you trying to return multiple rows?

if so you will have to use a loop: http://php.net/while
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post 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?
Post Reply