Php mysql查询的输出结果取决于mysql数组中选定的行
我有一个输出MySQL查询结果的PHP页面。每个输出行都有一个复选框。用户将检查所需的行并单击viewdetails按钮。然后我想显示MySQL查询的结果,这取决于用户的选择Php mysql查询的输出结果取决于mysql数组中选定的行,php,mysql,session,checkbox,Php,Mysql,Session,Checkbox,我有一个输出MySQL查询结果的PHP页面。每个输出行都有一个复选框。用户将检查所需的行并单击viewdetails按钮。然后我想显示MySQL查询的结果,这取决于用户的选择 SELECT * FROM table WHERE id = 'selected Checkbox's' 我的PHP页面如下: <?php mysql_connect("localhost", "hulamin_hulamin", "Hulamin2011")or die("cannot connect")
SELECT * FROM table WHERE id = 'selected Checkbox's'
我的PHP页面如下:
<?php
mysql_connect("localhost", "hulamin_hulamin", "Hulamin2011")or die("cannot connect");
mysql_select_db("hulamin_loc")or die("cannot select DB");
$sql="select loadid as `Order Number`, LOCStatus as `Load Status`,count(loadid) as `Number of Cases`,sum(`Gross Mass`) as `Total Weight`, customer as Customer, transporttypename as `Transport Type` from despgoods_alldetails where loadid > 0 group by loadid";
$result=mysql_query($sql);
$count=mysql_num_rows($result); ?> <table border=0>
<tr>
<td>
<form name="form1" method="post">
<table border=1
<tr>
<th> </th>
<th width=150>Order number</th>
<th width=150>Status</th>
<th width=150>Number of Cases</th>
<th width=130>Total Weight</th>
<th width=300>Customer</th>
<th width=150>Transport Type</th>
</tr> <?php
while($rows=mysql_fetch_array($result)){ ?>
<tr>
<td><input type="checkbox" name=check[] value="<?php echo $rows['Order Number']; ?>"></td>
<td><?php echo $rows['Order Number']; ?></td>
<td><?php echo $rows['Load Status']; ?></td>
<td><?php echo $rows['Number of Cases']; ?></td>
<td><?php echo $rows['Total Weight']; ?></td>
<td><?php echo $rows['Customer']; ?></td>
<td><?php echo $rows['Transport Type']; ?></td>
</tr>
<?php
} ?>
<tr>
<td colspan=7><input name="ViewDetails" type="submit" id="ViewDetails" value="ViewDetails"></td>
</tr>
<?php
$check=$_POST['check'];
if($_REQUEST['ViewDetails']=='ViewDetails'){
}
mysql_close(); ?> </table> </form> </td> </tr> </table>
任何帮助都将不胜感激
谢谢,
Ryan复选框的html是
<input type="checkbox" name="ids[]" />
及
那么MySQL查询应该是:
select * from desp_goods where loadid IN (implode(',', $ids))
嗨,谢谢你的回复。我对税收很满意。我不确定如何将变量$check(如上代码所示)带入下一页,因此查询将是[选择*从desp_货物哪里加载($check)]谢谢,我会试试这个吗?1,2,3,4代表什么?复选框的值<代码>等等。。替换1,2,3。。。根据您的值hanks@Janis,如果我正在从数组中检索,并且不知道将返回多少个复选框,我如何为每个复选框编号。我需要一个动态的方法来做到这一点。谢谢你,瑞安莱特
$ids = array(1,2,3,4);
select * from desp_goods where loadid IN (implode(',', $ids))