English 中文(简体)
1. 确定核查 表格各行各选的方框选入PHP
原标题:Determine if CheckBox in each row of table is selected in PHP

我目前正在实施一个PHP项目。 我正在从MySQL数据库中读到几句,并将其填入一个超文本表。

What I want to be able to do is to provide a checkbox on each row that the user can select. When they press a submit button it will check to see which checkboxes are clicked and remove them from the database.

我怎么能确定在报到时点击哪些检查箱。

感谢您能够提供的任何帮助。

最佳回答

我建议将这些身份证装入一个阵列。 这将使你的植物检疫逻辑更加容易,更糟。 这是一个非常基本的例子。

<><><><>>><>>>>><>>>>>>

<form action="..." method="post">
    <table>
        <tr><td><input type="checkbox" name="deleteId[]" value="1" /></td></tr>
        <tr><td><input type="checkbox" name="deleteId[]" value="2" /></td></tr>
        <tr><td><input type="checkbox" name="deleteId[]" value="3" /></td></tr>
    </table>
    <input type="submit" />
</form>

http://www.ohchr.org。

<?php
// If IDs were selected then delete from the database
if( isset($_POST[ deleteId ]) && count($_POST[ deleteId ]) >  0 )
{
    $sql =  DELETE FROM tablename WHERE id IN ( .implode( , , $_POST[ deleteId ]). ) ;
    mysql_query($sql);
}
else
{
    // no ids were selected
    // ...
}
?>
问题回答
<input type="checkbox" name="fieldname" value="somevalue" />

将向服务器提交

fieldname=somevalue

如果检查箱被检查。 如果没有检查,根本就没有提交。

通过向检查箱指定相关的外地名称,并将其价值与亚洲开发银行的记录识别资料相加,你能够看到检查箱的确切内容,并在相应的记录上删除。

You can add hidden field for each checkbox which can store value 0 or 1. When you select checkbox you should change value for this field using javascript. The similar approach uses by zend(I mean hidden fields). This approach helps you to solve problem with checkboxes which are not checked.





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签