我使用表格插入了一些值,併成功將值存儲在數據庫中。我使用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