21,886
社区成员
发帖
与我相关
我的任务
分享
<td width="40"><input id="subBox" name="subBox" type="checkbox" value="<?php echo $row->id;?>"></th>
function piliang_daochu()
{
var chckBox = document.getElementsByName("subBox");
var num = chckBox.length;
var ids = "";
for(var index =0 ; index<num ; index++){
if(chckBox[index].checked){
ids=ids + chckBox[index].value+",";
}
}
var strs= new Array();
strs=ids.split(",");
if(ids!=""){
if(window.confirm("确定导出所选记录?")){
$.ajax( {
type:'GET',
url:"daochu.php",
data:{
text:strs
},
success : function(data) {
alert("导出成功");
},
error : function(data) {
alert("系统错误,导出失败");
}
});
}
}else{
alert("请选择要导出的记录");
}
}
$conn=mysql_connect("localhost","root","rootroot") or die("数据库服务器连接错误".mysql_error());
mysql_select_db("aitem",$conn) or die("数据库访问错误".mysql_error());
mysql_query("set names utf8");
$id=$_GET[text];
$boxgeshu=count($id);
for ($i=0;$i<($boxgeshu-1);$i++)
{
$sql = "select * from iteminfo where id='$id[$i]'";
$query = mysql_query($sql);
while($row = mysql_fetch_assoc($query))
{
$arr[] = $row;
}
echo mysql_error();
}
if(isset($_GET['text'])){
echo 'select * from iteminfo where id in (' . implode (',',$_GET['text']) . ')';
exit();
}
<?php
if(isset($_GET['text'])){
echo 'select * from iteminfo where id in (' . implode (',',$_GET['text']) . ')';
exit();
}
?>
<table>
<form method="post" action="?">
<tr>
<td width="40"><input id="subBox" name="subBox" type="checkbox" value="1">1</td>
</tr>
<tr>
<td width="40"><input id="subBox" name="subBox" type="checkbox" value="2">2</td>
</tr>
<tr>
<td width="40"><input id="subBox" name="subBox" type="checkbox" value="3">3</td>
</tr>
<tr>
<td width="40"><input type="button" value="提交" onclick="piliang_daochu()"></td>
</tr>
</form>
</table>
sql:<span id="res"></span>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
function piliang_daochu()
{
var chckBox = document.getElementsByName("subBox");
var num = chckBox.length;
var ids = "";
for(var index =0 ; index<num ; index++){
if(chckBox[index].checked){
ids=ids + chckBox[index].value+",";
}
}
var strs= new Array();
strs=ids.split(",");
strs.pop();
if(ids!=""){
if(window.confirm("确定导出所选记录?")){
$.ajax( {
type:'GET',
url:"form2.php",
data:{
text:strs
},
success : function(data) {
alert("导出成功");
$('#res').text(data);
},
error : function(data) {
alert("系统错误,导出失败");
}
});
}
}else{
alert("请选择要导出的记录");
}
}
</script>