[英]output results of mysql query that is dependant on selected rows from MySQL array
I have a PHP page that outputs the results of a MySQL query. 我有一个PHP页面,它输出MySQL查询的结果。 each outputted row has a checkbox.
每个输出行都有一个复选框。 The user will check the desired rows and click a viewdetails button.
用户将检查所需的行,然后单击viewdetails按钮。 I want to then display the results of the MySQL query that is dependant on the users selections.
然后,我想显示取决于用户选择的MySQL查询的结果。
SELECT * FROM table WHERE id = 'selected Checkbox's'
My PHP page is as follows: 我的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>
After clicking the submit button I want the query to run and output results 单击提交按钮后,我希望查询运行并输出结果
select * from desp_goods where loadid=$checkboxes
Any help would be appreciated. 任何帮助,将不胜感激。
Thanks, Ryan 谢谢,瑞安
html for checkbox is 复选框的html是
<input type="checkbox" name="ids[]" />
and your post $_POST array is something like this 而您的帖子$ _POST数组是这样的
$ids = array(1,2,3,4);
and 和
MySQL query then should be: MySQL查询则应为:
select * from desp_goods where loadid IN (implode(',', $ids))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.