我有一個問題,我如何將數據插入MySql數據庫與JavaScript?javascript:如何將數據插入到mysql
我有以下JS代碼:
function saveData()
{
var table = document.getElementById('tblResult');
var rowCount = table.rows.length;
i = rowCount;
var template = "<tr> <td>"+i+"</td> <td>"+document.getElementById('ctrl_ball_size_val').value+"</td> <td style='text-align: center; background-color: lime;'>± 0.1</td> <td>"+document.getElementById('ctrl_cilindr_height_val').value+"</td> <td style='text-align: center; background-color: lime;'>± 0.1</td> <td>"+document.getElementById('stopwatch').value+"</td> <td style='text-align: center; background-color: lime;'>± 0.1</td> <td>11300</td> <td style='text-align: center; background-color: lime;'>± 0.1</td> <td>1260</td> <td style='text-align: center; background-color: lime;'>± 0.1</td> </tr>";
$('tbody').append(template);
}
與此代碼我建立與動態數據的表格是我從HTML頁面上輸入了。 下面是表中的HTML代碼:
<table id="tblResult" class="zebra-striped">
<thead>
<tr>
<th id="ID">Nr.p.k</th>
<th>d ± △d, mm</th>
<th style="background-color: lime;">△d, mm</th>
<th>l ± △l, cm</th>
<th style="background-color: lime;">△l, cm</th>
<th>t ± △t, s</th>
<th style="background-color: lime;">△t, s</th>
<th>p ± △p, kg/m<sup>3</sup></th>
<th style="background-color: lime;">△p, kg/m<sup>3</sup></th>
<th>p<sub>1</sub> ± △p<sub>1</sub>, kg/m<sup>3</sup></th>
<th style="background-color: lime;">△p<sub>1</sub>, kg/m<sup>3</sup></th>
</tr>
</thead>
<tbody></tbody>
</table>
,其中我插入此動態數據。 所以我需要插入/保存所有的HTML表格到MySQL數據庫中,這個表格將顯示在第二頁上,但是如何組織這些數據插入然後顯示我不知道......任何人都可以幫助我嗎?
聽起來像是[AJAX](https://en.wikipedia.org/wiki/Ajax_(編程)) – showdev 2013-04-09 20:58:52
@showdev一個工作,你可以提供有關如何使用Ajax做一些例子嗎? – vladimir 2013-04-09 21:01:04
您必須使用服務器端編程語言與數據庫進行交互。 – js1568 2013-04-09 21:12:33