我使用表格插入了一些值,并成功将值存储在数据库中。我使用while循环使用HTML编码将存储的值回显到表中。并且我编辑了所有可编辑的td(表格内容)。由于我是编程新手,努力将编辑的值存储到数据库,任何人都可以帮助任何查询,概念?无法将编辑的内容存储到数据库中
我的代码
<?php
if(isset($_GET['id']))
{
$qry="DELETE FROM nifty WHERE id =" .$_GET['id'];
mysql_query($qry);
}
if(isset($_GET['rid']))
{
$qry1="UPDATE nifty WHERE id =" .$_GET['rid'];
mysql_query($qry1);
echo $qry1;
}
$result = mysql_query("SELECT * FROM nifty");
echo "<table class='table table-bordered'>
<tr>
<th>Date</th>
<th>B/S</th>
<th>Entry Point</th>
<th>Exit Point</th>
<th>P/L</th>
<th style='width:50px;'>Action</th>
</tr>";
while($row = mysql_fetch_array($result)) {
echo "<tr>";?>
<td contenteditable="true">
<?php echo $row['date']; ?>
</td>
<td contenteditable="true">
<?php echo $row['bs']; ?>
</td>
<td contenteditable="true">
<?php echo $row['entrypoint']; ?>
</td>
<td contenteditable="true">
<?php echo $row['exitpoint']; ?>
</td>
<td contenteditable="true">
<?php echo $row['pl']; ?>
</td>
<td width=10%>
<?php echo "<a href='?rid=".$row['id']."' title='Sure You want to save this Record;' onClick=\"return confirm('Are you sure to save this Record?');\"><img src='images/edit.png'></a>"; ?>  <?php echo "<a href='?id=".$row['id']."' title='You want to cancel this booking;' onClick=\"return confirm('Are you sure to delete this record?');\"><img src='images/delete.png'></a>"; ?></td>
<?php
echo "</tr>";
}
echo "</table>";?>
嗨@sheik可变
$ required_date =日期,你能解释一下我关于你的问题的细节? – 2015-02-23 06:32:42
我在这里没有看到任何表单输入。您需要创建一个表单,将您想要更新的字段发布到您的脚本。然后运行'UPDATE'查询来保存它们,例如'UPDATE nifty SET field ='value'WHERE id = id;'... – grimmdude 2015-02-23 06:33:42
应该可以在数据库中编辑和更新回显的数据库内容@Karthik N – Sheik 2015-02-23 06:43:21