$_Post question with buttons/links

I’m trying to display a table in which several columns have buttons that call other scripts. I’m not sure how to transfer values through $_POST using this, though. For example, for the code [php]echo "

<form action=“insertPosts.php?id=$row[0]” method =“post”>";

echo “<input type=“submit” value=“DELETE”>

”;[/php]

that would be displayed on each row of the table how do I transfer only the data of a particular row on the table to the called script insertPosts.php? Does the $row[0] variable in the code above affect this, or do I need to add another field such as “name” to the form action?

Additionally, is there a way to place a column of links in the table so that each one will transfer data through $_POST or $_GET, such as with
[php] echo “<a href=“update” title=“Change values””;[/php]

so that when a link in a particular row is clicked, the values in that row and only that row will be passed by $_Post to update.php? Thanks in advance for any help that can be provided.

ok-2 things.

1 - if you’re using strictly urls to do things, you don’t need the form and
2 - if you’re using forms and need to transfer data that’s not normally visible, like id’s, then you’d use hidden inputs.

With urls, the capture will be done by $_GET and generally, with forms, its done by $_POST or $_REQUEST (though request is quite a bit outdated and not used that often)

Your first example would be
[php]
ifisset($_POST[‘delete’])) {
$row = $_POST[‘row0’];
$del = mysql_query(“DELETE FROM table WHERE row = ‘$row’”) or die(mysql_error());
}

echo "



";[/php]

Your 2nd example is incomplete, but this is close
[php]
//on update.php
if(!empty($_GET[‘id’])) {
$id = $_GET[‘id’];

// more code
}

// other page
echo “Change values”;[/php]

Hopefully that clears somethings up.

Sponsor our Newsletter | Privacy Policy | Terms of Service