我有一個PHP表單,如下所示。一旦用戶選擇了特定的行/行,我需要將相應的數據發送到我的PHP後端腳本。這裏的externalID是唯一的。我的臉在我的代碼的兩個問題如何將選定的html行數據發送到PHP後端腳本
目前我得到整個表單數據到我的PHP腳本的後臺,我需要相當於只有我選擇的行數據。
我在頁面中有兩個按鈕,我怎樣才能在點擊按鈕時調用不同的php腳本。目前,點擊「發送MTDATA」在表單動作中調用php腳本。
SRC代碼:
<form target="iframe_b" action="/php_src/first.php" method="POST"
echo "sending data">
<fieldset>
<br><br>
<input type="button" id="activate_device" name="activatedevice" value="Activate_device">
<input type="submit" value="SEND MTDATA">
<table border="1">
<tr>
<th><input type="checkbox" id="selectall"/></th>
<th>External ID</th>
<th>Status</th>
</tr>
<?php
$dbhost = 'localhost:3036';
$dbuser = 'root';
$dbpass = 'xxxx';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$conn) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("ApplicationServer") or die(mysql_error());
// Get all the data from the "example" table
$result = mysql_query("SELECT EXTERNAL_ID,CONNECTION_STATUS FROM DEVICE_DETAILS") or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$extID = $row['EXTERNAL_ID'];
$conStatus = $row['CONNECTION_STATUS'];
echo "</tr><tr>";
echo "</td><td>";
echo "<input type=\"checkbox\" class=\"case\" name=\"checkBox".$extID."\" />";
echo "</td><td>";
echo "<input type=\"text\" class=\"classextID\" value=\"$extID\" name=\"textExID".$extID."\" />";
echo "</td><td>";
echo "<input type=\"text\" class=\"classConnection\" value=\"$conStatus\" name=\"textcon".$extID."\" />";
}
?>
</table>
</fieldset>
</form>
輸出:
array(9) { ["[email protected]_com"]=> string(2) "on" ["[email protected]_com"]=> string(19) "[email protected]" ["[email protected]_com"]=> string(16) "request accepted" ["[email protected]_com"]=> string(2) "on" ["[email protected]_com"]=> string(17) "[email protected]" ["[email protected]_com"]=> string(16) "request accepted" ["[email protected]_com"]=> string(2) "on" ["[email protected]_com"]=> string(18) "[email protected]" ["[email protected]_com"]=> string(16) "request accepted" }
我建議您在其個人資料中看到OP的最新問題。他們正在慢慢從其他答案獲取代碼並從其上重新發布。我關閉了他們的最新版本,與他們在此發佈的版本完全相同。 –
@ Fred-ii-嗯,這不太好,我必須記住這一點... – jeroen
我發現在OP的某些模式上更好些;-) –