How to transfer a specific data through get method

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
tanveer
Forum Newbie
Posts: 9
Joined: Sat Mar 27, 2004 11:07 am

How to transfer a specific data through get method

Post by tanveer »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi all:
I have a simple table with 4 fields and showing them in a webpage as report. Now with that list I want to show a delete link with each row and when user clicks on that delete link then that particular row will be deleted. 

I have a unique field named [b]id[/b] in my table. Now how to send the value of [b]id[/b] to the delete page so that it that particular row can be deleted.

Below is a part of the code for just showing the result but how to pass a value through link?

Code: Select all

while($row=mysql_fetch_row($result))
{ 

        echo "<tr>";
 	 
	if( date($row[4]) == date('Y-m-d') ) 
	{
	       
	   for ($i=1;$i<$num_fields;$i++)	 
	    {
			echo '<td bgcolor="#CCCCCC"><b>'; 
			echo $row[$i];
			echo '</b></td>';
	    }
		    echo '</tr>';
    }
    else
    {
	   
      for($i=1;$i<$num_fields;$i++)
      {
   	    echo '<td>';
  	    echo $row[$i];
  	    echo '</td>';
       }
          echo '</tr>';
     }
    
 }		  
   
 ?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
choppsta
Forum Contributor
Posts: 114
Joined: Thu Jul 03, 2003 11:11 am

Post by choppsta »

you would do something like:

Code: Select all

$link = '<a href="deleteScript.php?id='.$row['idField'].'">Delete Me</a>';
However, it is NOT considered good practice to perform any requests that change things using a GET request. You should really use a POST request. I normally do this by having checkboxes for each entry. This has the added benefit that the user can delete multiple items in one go.
tanveer
Forum Newbie
Posts: 9
Joined: Sat Mar 27, 2004 11:07 am

Post by tanveer »

Thanks a lot, it worked.
And as you said to use a checkbox then how to pass the id value for each specific row as I am using link now?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Typically, the value attribute of the check box is used to pass that information.
Post Reply