我正在制作一個(gè)功能,它在數(shù)據(jù)庫(kù)中按行顯示商店,每個(gè)商店后面都有一個(gè)按鈕,每個(gè)商店前面都有一個(gè)復(fù)選框。我想找到另一種根據(jù)按下的按鈕獲取商店 ID 的方法。選擇按鈕的商店將從數(shù)據(jù)庫(kù)中刪除。$sql = "SELECT * FROM alb_locaties WHERE Verwijderd = '0'";$result = $conn->query($sql);if ($result->num_rows > 0){ echo "<form action='' method='get'>"; echo "<table id='MainTable'> <tr> <th></th> <th>Shopnaam</th> <th></th> </tr>"; while ($row = $result->fetch_assoc()){ $ID = $row['I_id']; echo "<tr> <td><input type='checkbox' name='Shops[]' value='$ID'></td> <td>$ID</td> <input type='hidden' name='givenID' value='$ID'> <td><a href=\"Reset_locatieshops.php?givenID='$ID'\"><input type='button' value='Verwijder'/></a></td> </tr>"; } echo "</table>"; echo "<input id='SelectionButton' type='submit' name='SelectionDelete' value='Verwijder selectie'/>"; echo "</form>";}if (isset($_GET['givenID'])){ $selectedID = $_GET['givenID']; // FIRST DELETE $sql = "SELECT * FROM alb_locaties INNER JOIN alb_afdelingen ON alb_locaties.I_id = alb_afdelingen.locaties WHERE alb_locaties.I_id = {$selectedID}";現(xiàn)在它由<a href=\"Reset_locatieshops.php?givenID='$ID'\">and決定$selectedID = $_GET['givenID'];,但我寧愿使用一種在 URL 中不顯示 ID 的方式。Post 似乎也是一個(gè)更好的選擇,因?yàn)楝F(xiàn)在當(dāng)我刷新頁(yè)面時(shí),由于 URL 中的 ID,它會(huì)再次執(zhí)行查詢(xún)。我怎樣才能仍然獲得 ID,但使用不同的方法。
1 回答

慕尼黑5688855
TA貢獻(xiàn)1848條經(jīng)驗(yàn) 獲得超2個(gè)贊
沒(méi)關(guān)系,我找到了。我將表單方法更改為發(fā)布,
我將其更改<a href=\"Reset_locatieshops.php?givenID='$ID'\"><input type='button' value='Verwijder'/></a>
為<input type='submit' value='Verwijder' name='submit'>
.
在那之后,我曾經(jīng)$selectedID = $_POST['givenID'];
得到給予的ID<input type='hidden' name='givenID'
- 1 回答
- 0 關(guān)注
- 106 瀏覽
添加回答
舉報(bào)
0/150
提交
取消