这是我页面代码,我想让删除和编辑按钮起作用应该怎么改 大侠帮帮忙了
最好给个实例谢谢了 在线等
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>index</title>
</head><body>
<table width="100%" height="561" >
<tr>
<td height="50" colspan="2" bgcolor="#F5F5F5"></td>
</tr>
<tr>
<td width="15%" height="414" bgcolor="#F5F5F5" ></td>
<td width="85%" valign="top">
<table width="100%">
<tr>
<td colspan="2"><input type="button" name="button" value="添加" onclick="window.open ('TJ.php','newwindow','height=400, width=500, top=50, left=100, toolbar=no, menubar=no, scrollbars=no,resizable=no,location=no, status=no');">
</td>
</tr>
<tr>
<td colspan="2" valign="top">
<?php
$db_host="127.0.0.1:3306";
$db_user="root";
$db_psw="";
$db_name="mysql";
$connection=mysql_connect($db_host,$db_user,$db_psw)or die("连接服务器失败");
mysql_select_db($db_name,$connection)or die("选择数据库失败");
echo "<table border=1>"; //输出表头
echo "<tr bgcolor=#0099CC><th>h_id</th><th>hotel_id</th><th>start_date</th><th>end_date</th><th>content</th><th>source</th><th>s_type</th><th>操作</th></tr>";
$result = mysql_query("SELECT * FROM hotel_activities_2"); //在mytable表上执行SQL语句 while ($row = mysql_fetch_assoc($result)) {
echo '<tr>';
echo '<td>'.$row['h_id'].'</td>';
echo '<td>'.$row['hotel_id'].'</td>';
echo '<td>'.$row['start_date'].'</td>';
echo '<td>'.$row['end_date'].'</td>';
echo '<td>'.$row['content'].'</td>';
echo '<td>'.$row['source'].'</td>';
echo '<td>'.$row['s_type'].'</td>';
echo '<td>'.' <input type="submit" name="submit" value="删除"> '.' <input type="submit" name="submit" value="编辑"> '.'</td>';
echo '</tr>';
}
echo "</table>";
mysql_close($connection); //关闭与数据库的连接
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
最好给个实例谢谢了 在线等
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>index</title>
</head><body>
<table width="100%" height="561" >
<tr>
<td height="50" colspan="2" bgcolor="#F5F5F5"></td>
</tr>
<tr>
<td width="15%" height="414" bgcolor="#F5F5F5" ></td>
<td width="85%" valign="top">
<table width="100%">
<tr>
<td colspan="2"><input type="button" name="button" value="添加" onclick="window.open ('TJ.php','newwindow','height=400, width=500, top=50, left=100, toolbar=no, menubar=no, scrollbars=no,resizable=no,location=no, status=no');">
</td>
</tr>
<tr>
<td colspan="2" valign="top">
<?php
$db_host="127.0.0.1:3306";
$db_user="root";
$db_psw="";
$db_name="mysql";
$connection=mysql_connect($db_host,$db_user,$db_psw)or die("连接服务器失败");
mysql_select_db($db_name,$connection)or die("选择数据库失败");
echo "<table border=1>"; //输出表头
echo "<tr bgcolor=#0099CC><th>h_id</th><th>hotel_id</th><th>start_date</th><th>end_date</th><th>content</th><th>source</th><th>s_type</th><th>操作</th></tr>";
$result = mysql_query("SELECT * FROM hotel_activities_2"); //在mytable表上执行SQL语句 while ($row = mysql_fetch_assoc($result)) {
echo '<tr>';
echo '<td>'.$row['h_id'].'</td>';
echo '<td>'.$row['hotel_id'].'</td>';
echo '<td>'.$row['start_date'].'</td>';
echo '<td>'.$row['end_date'].'</td>';
echo '<td>'.$row['content'].'</td>';
echo '<td>'.$row['source'].'</td>';
echo '<td>'.$row['s_type'].'</td>';
echo '<td>'.' <input type="submit" name="submit" value="删除"> '.' <input type="submit" name="submit" value="编辑"> '.'</td>';
echo '</tr>';
}
echo "</table>";
mysql_close($connection); //关闭与数据库的连接
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
比如:
......
echo '<td>'.$row['source'].'</td>';
echo '<td>'.$row['s_type'].'</td>';
echo '<td>'.' <form acrion=""> <input type="submit" name="submit" value="删除"> </form> '.' <form action=""> <input type="submit" name="submit" value="编辑"> </form> '.'</td>';
echo '</tr>';是这让写么
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>index</title>
</head><body>
<table width="100%" height="561" >
<tr>
<td height="50" colspan="2" bgcolor="#F5F5F5"></td>
</tr>
<tr>
<td width="15%" height="414" bgcolor="#F5F5F5" ></td>
<td width="85%" valign="top">
<table width="100%">
<tr>
<td colspan="2"><input type="button" name="button" value="添加" onclick="window.open ('TJ.php','newwindow','height=400, width=500, top=50, left=100, toolbar=no, menubar=no, scrollbars=no,resizable=no,location=no, status=no');">
</td>
</tr>
<tr>
<td colspan="2" valign="top"><form action="?" method="post" name="listForm" id="listForm">
<?php
$db_host="127.0.0.1:3306";
$db_user="root";
$db_psw="";
$db_name="mysql";
$connection=mysql_connect($db_host,$db_user,$db_psw)or die("连接服务器失败");
mysql_select_db($db_name,$connection)or die("选择数据库失败");
echo "<table border=1>"; //输出表头
echo "<tr bgcolor=#0099CC><th>h_id</th><th>hotel_id</th><th>start_date</th><th>end_date</th><th>content</th><th>source</th><th>s_type</th><th>操作</th></tr>";
$result = mysql_query("SELECT * FROM hotel_activities_2"); //在mytable表上执行SQL语句 while ($row = mysql_fetch_assoc($result)) {
echo '<tr>';
echo '<td>'.$row['h_id'].'</td>';
echo '<td>'.$row['hotel_id'].'</td>';
echo '<td>'.$row['start_date'].'</td>';
echo '<td>'.$row['end_date'].'</td>';
echo '<td>'.$row['content'].'</td>';
echo '<td>'.$row['source'].'</td>';
echo '<td>'.$row['s_type'].'</td>';
echo '<td>'.' <input type="button" name="submit" value="删除" onclick="iSubmit(?action=drop&id='.$row['h_id'].');"> '.' <input type="button" name="submit" value="编辑" onclick="iSubmit(?action=edit&id='.$row['h_id'].');"> '.'</td>';
echo '</tr>';
}
echo "</table>";
mysql_close($connection); //关闭与数据库的连接
?>
</form></td>
</tr>
</table>
</td>
</tr>
</table>
<script language="javascript">
function iSubmit( url ){
document.getElementById("listForm").action = url;
document.getElementById("listForm").submit();
}
</script>
</body>
</html>
<?php
$db_host="127.0.0.1:3306";
$db_user="root";
$db_psw="";
$db_name="mysql";
$connection=mysql_connect($db_host,$db_user,$db_psw)or die("连接服务器失败");
mysql_select_db($db_name,$connection)or die("选择数据库失败");
echo "<table border=1>"; //输出表头
echo "<tr bgcolor=#0099CC><th>h_id</th><th>hotel_id</th><th>start_date</th><th>end_date</th><th>content</th><th>source</th><th>s_type</th><th>操作</th></tr>";
$result = mysql_query("SELECT * FROM hotel_activities_2"); //在mytable表上执行SQL语句 while ($row = mysql_fetch_assoc($result)) {
echo <<< HTML
<tr>
<td>$row[h_id]</td>
<td>$row[hotel_id]</td>
<td>$row[start_date]</td>
<td>$row[end_date]</td>
<td>$row[content]</td>
<td>$row[source]</td>
<td>$row[s_type]</td>
<td><form action="test.php?job=del"> <input type="hidden" value="$row[h_id]">
<input type="submit" name="submit" value="删除"></form> <form action="test.php?job=edit"><input type="hidden" value="$row[h_id]"><input type="submit" name="submit" value="编辑"></form></td>
</tr>
HTML;
}
//其实你可以直接把删除和编辑的按钮换成连接.<a href="del.php?hid={$row[h_id]}">删除</a>
//<a href="edit.php?hid={$row[h_id]}">编辑</a>
//就不用加form表单了
echo "</table>";
mysql_close($connection); //关闭与数据库的连接
?>