[英]INSERT INTO multiple rows from a dynamic html table to MYsql using PHP
[英]How can I insert multiple rows in mysql from an html table that used php echo for display
我得到了這段代碼,該代碼生成一個表格並與循環錦標賽系統中的團隊進行匹配。
我在tbl_teams
上檢索了3個團隊,並將其顯示在創建游戲並將每個團隊彼此匹配的表上。 就是這樣
我從代碼的tbl_teams
輸出中獲得了team1,team2和team3:
team1 vs team3
team2 vs team0
team3 vs team2
問題:如何在tbl_games
保存此輸出? 我使用PHP echo
在表上顯示輸出,這使得保存起來很困難。
這是我的代碼:
<th width="35%">Group 1 Match</th>
<th></th>
<th width="35%"></th>
<th width="15%">Date of Game</th>
<th width="15%">Time of Game</th>
<tr><td><b>Round 1</td></b></tr>
<tr>
<td>   <?php echo $x[0]->team_name; ?></td>
<td>VS</td>
<td>   <?php echo $x[2]->team_name; ?></td>
<td><input type="date" name="date"></td><td><input type="time" name="time"></td>
</tr>
<tr><td><b>Round 2</td></b></tr>
<tr>
<td>   <?php echo $x[1]->team_name; ?></td>
<td>VS</td>
<td>   <?php echo $x[0]->team_name; ?></td>
<td><input type="date" name="date"></td><td><input type="time" name="time"></td>
</tr>
<tr><td><b>Round 3</td></b></tr>
<tr>
<td>   <?php echo $x[2]->team_name; ?></td>
<td>VS</td>
<td>   <?php echo $x[1]->team_name; ?></td>
<td><input type="date" name="date"></td><td><input type="time" name="time"></td>
</tr>
$x[0]
, [1]
和[2]
包含我的查詢結果,這是3個團隊
您不會將整個呈現的HTML表存儲在數據庫中,尤其是因為您不能(輕松地)將PHP代碼包括在數據庫表中存儲的代碼段中。 相反,您存儲用於創建表的數據的各個位,並在每次從數據庫加載表時使用PHP代碼重新呈現該表。
如果您確實堅持將整個呈現的HTML表存儲在數據庫中,則必須將其呈現一次,然后將呈現的HTML放入數據庫中。 即,所有PHP部分均已評估,並替換為純HTML。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.