php – 如何检查已提交的按钮
发布时间:2020-12-13 16:54:33 所属栏目:PHP教程 来源:网络整理
导读:我有一个表格,像这样: echo 'table align=center border=1';echo 'form method="post"';echo 'tr';echo 'thLista Echipamente/th';echo 'thActiune/th';echo '/tr';while($row=mysql_fetch_array($sql)){echo 'tr'; echo 'tdinput class="search-logi" id="
我有一个表格,像这样:
echo '<table align=center border=1>'; echo '<form method="post">'; echo '<tr>'; echo '<th>Lista Echipamente</th>'; echo '<th>Actiune</th>'; echo '</tr>'; while($row=mysql_fetch_array($sql)){ echo '<tr>'; echo '<td><input class="search-logi" id="tip" type="text" name="tip" value="'.$row['tip'].'"></td>'; echo '<td><input type=submit name=modifica value=Modifica></td>'; echo '</tr>'; } echo '</form>'; echo '</table>'; 由于循环,此表单将具有多行.对于每个输入,将是一个按钮. 解决方法
或者,您可以使用< button>用于此目的的标签:
echo '<form method="post">'; // form tags are outside to be valid!!! echo '<table align=center border=1>'; echo '<tr>'; echo '<th>Lista Echipamente</th>'; echo '<th>Actiune</th>'; echo '</tr>'; while($row = mysql_fetch_assoc($sql)){ echo '<tr>'; echo '<td><input class="search-logi" type="text" name="tip['.$row['id'].']" value="'.$row['tip'].'"></td>'; echo '<td><button type="submit" name="modifica" value="'.$row['id'].'">Modifica</button</td>'; echo '</tr>'; } echo '</table>'; echo '</form>'; 然后在处理表格上: $modifica = $_POST['modifica']; // shoud return the index num $tip = $_POST['tip'][$modifica]; // select which textbox (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |