I am trying to create a form with two buttons - "DELETE", which runs on the delete.php page and "EDIT", which runs on edit.php.
So I need another action, depending on which button they pressed ...
Here is my code.
$con = mysql_connect("localhost","user","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("test", $con); $result = mysql_query("SELECT * FROM myTable"); // Need to change the action depending on what button is clicked echo "<form name='wer' id='wer' action='delete.php' method='post' >"; echo "<table border='1'>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['id'] . "</td>"; echo "<td>" . $row['page_title'] . "</td>"; echo "<td><input type='radio' name='test1' value='" . $row['id'] . "' /></td>"; echo "</tr>"; } echo "<tr>"; echo "<td> </td>"; echo "<td> </td>"; echo "<td><input type='submit' name='delete' value='Delete' /> <input type='submit' name='edit' value='Edit' /></td>"; echo "</tr>"; echo "</table>"; echo "</form>"; mysql_close($con);
source share