Php 具有原样/更新/删除功能的单选按钮
所以我创建了一个有3个单选按钮的表。我很难理解如何让每个单选按钮执行它们指定的任务[功能]。这是我桌子的一张照片: 有人能解释一下或给我举个例子,说明如何赋予这些单选按钮功能吗。因此,当编辑文本时,如果选择了update,并单击submit按钮,则会更新数据库 以下是我在本节中的代码:Php 具有原样/更新/删除功能的单选按钮,php,mysql,button,radio,updating,Php,Mysql,Button,Radio,Updating,所以我创建了一个有3个单选按钮的表。我很难理解如何让每个单选按钮执行它们指定的任务[功能]。这是我桌子的一张照片: 有人能解释一下或给我举个例子,说明如何赋予这些单选按钮功能吗。因此,当编辑文本时,如果选择了update,并单击submit按钮,则会更新数据库 以下是我在本节中的代码: <!DOCTYPE html PUBLIC> <?php $connection = mysql_connect('localhost', 'root', 'root'); //Test C
<!DOCTYPE html PUBLIC>
<?php
$connection = mysql_connect('localhost', 'root', 'root');
//Test Connection
if (!$connection)
{
die ("Could not connct to the database: <br />". mysql_error());
}
//select db
mysql_select_db('Assets');
$sql1= "SELECT gid, gstmnt FROM Goals";
$records1 = mysql_query($sql1);
//Adding functions to submit
//$gstmnt_up = $_POST['gstmnt'];
?>
<html>
<head>
<title>List of GOALS/List of SERVICES</title>
</head>
<body>
<table width='800' border='3' cellpadding='2' cellspacing='2'>
<tr>
<h1>List of Goals</h1>
<th>GID</th>
<th width= '200'>Goal Statement</th>
<!--Sumbit column-->
<th width= '85'>
<form id="EditGoalForm" action="EditGoals.php" method="POST">
<input type="submit" name="submit" value="Submit"/>
</form>
</th>
</tr>
<!--This is a paragraph. It is editable. Try to change this text.</p>-->
<?php
while ($gtable = mysql_fetch_assoc($records1)) {
echo "<tr>";
echo "<td>".$gtable['gid']."</td>";
echo "<td><div id=textarea contenteditable>".$gtable['gstmnt']."</div></td>";
echo "<td>
<input type='radio' name=".$gtable['gid']." value='asis' checked> AS-IS </br>
<input type='radio' name=".$gtable['gid']." id='radio_update".$gtable['gid']." value='update' > Update </br>
<input type='radio' name=".$gtable['gid']." value='delete' > Delete
</td>";
echo "</tr>";
}
echo "<td> </td>";
echo "<td>
<input type= 'text name='addGoal' placeholder='ADD NEW GOAL HERE' size='100'>
</td>";
echo "<td>
<input type='checkbox' name='add' value='checked'> Add Goal
</td>";
?>
</table>
谷歌更新mysql。我知道如何使用如下语法来更新mysql:updatetable_name SET column1=value,column2=value2,。。。其中some_column=some_value现在我的问题是将单选按钮连接到该语法。现在,让我们看看您尝试了哪些可能失败的方法。如果没有,那么继续搜索。有很多例子,你不需要我们。