to submit the form on same page based on different submit buttons
I have three buttons on a page and i want to submit that form on the same
page, according to the button press query should be run.But there are some
problem in script.
<?php
$db = mysql_connect('localhost', 'root', '') or
die ('Unable to connect. Check your connection parameters.');
mysql_select_db('easy_excel', $db) or die(mysql_error($db));
if ($_POST['submit'] =='delete_aabb')
{
$query ='DELETE FROM aabb';
mysql_query($query, $db) or die(mysql_error($db));
echo 'All Data from aabb Deleted succecfully!';
}
elseif ($_POST['submit'] =='delete_bbcc') {
$query ='DELETE FROM bbcc';
mysql_query($query, $db) or die(mysql_error($db));
echo 'All Data from bbcc Deleted succecfully!';
}
elseif ($_POST['submit'] =='show_bbcc') {
$query = 'SELECT
name
FROM bbcc';
$result = mysql_query($query, $db) or die(mysql_error($db));
echo '<table border="1">';
while ($row = mysql_fetch_assoc($result)) {
echo '<tr>';
foreach ($row as $value) {
echo '<td>' . $value . '</td>';
}
echo '</tr>';
}
echo '</table>';
}
?>
<html>
<head>
<title>Say My Name</title>
</head>
<body>
<form action="#" method="post">
<table>
<tr>
<input type="submit" name="submit" value="delete_aabb" />
</tr>
<tr>
<input type="submit" name="submit" value="delete_bbcc" /></td>
</tr>
<tr>
<input type="submit" name="submit" value="show_bbcc" /></td>
</tr>
</table>
</form>
</body>
</html>
But this script is not running.please help me.
No comments:
Post a Comment