001.
<?php
002.
SESSION_START();
003.
require_once
(
'config.php'
);
004.
require_once
(
'class/class.upload.php'
) ;
005.
006.
$ven
=
$conn
->query(
"SELECT * FROM itemforuser "
);
007.
$numr
=
$ven
->num_rows;
008.
?>
009.
010.
<html>
011.
<head>
012.
<meta charset=
"utf-8"
>
013.
<title>test</title>
014.
<script type=
"text/javascript"
src=
"jquery.js"
></script>
015.
<script type=
"text/javascript"
src=
"jquery.dataTables.min.js"
></script>
016.
<link rel=
"stylesheet"
type=
"text/css"
href=
"jquery.dataTables.min.css"
>
017.
<script type=
"text/javascript"
>
018.
function
MM_goToURL() {
019.
var
i, args=MM_goToURL.arguments; document.MM_returnValue = false;
020.
for
(i=0; i<(args.length-1); i+=2)
eval
(args[i]+
".location='"
+args[i+1]+
"'"
);
021.
}
022.
</script>
023.
<script>
024.
$(
'input[type=checkbox]'
).live(
"change"
,
function
(){
025.
var
target = $(this).parent().find(
'input[type=hidden]'
).val();
026.
if
(target == 0)
027.
{
028.
target = 1;
029.
}
030.
else
031.
{
032.
target = 0;
033.
}
034.
$(this).parent().find(
'input[type=hidden]'
).val(target);
035.
});
036.
</script>
037.
</head>
038.
039.
<body>
040.
<div align=
"center"
>
041.
<form id=
"MyForm"
method=
"POST"
action=
""
>
042.
<table width=
"70%"
border=
"1"
id=
"myTable"
>
043.
<thead>
044.
<tr>
045.
<th width=
"5%"
><div align=
"center"
>NO.</div></th>
046.
<th width=
"10%"
><div align=
"center"
>ACCOUNT CODE</div></th>
047.
<th width=
"25%"
><div align=
"center"
>ITEM NAME</div></th>
048.
<th width=
"5%"
><div align=
"center"
></div></th>
049.
</tr>
050.
</thead>
051.
<tbody>
052.
053.
<?php
054.
055.
$i
=0;
056.
057.
while
(
$i
<
$numr
&&
$ven2
=
$ven
->fetch_assoc())
058.
{
$i
++;
059.
060.
?>
061.
<tr>
062.
<td><center><input type=
"hidden"
name=
"txtID[]"
value=
"<?php echo $ven2["
id
"];?>"
><?php
echo
$ven2
[
"id"
];?></center></td>
063.
<td><center><input type=
"hidden"
name=
"txtACC[]"
value=
"<?php echo $ven2["
acc_name
"];?>"
><?php
echo
$ven2
[
"acc_name"
];?></center></td>
064.
<td><input type=
"hidden"
name=
"txtITM[]"
value=
"<?php echo $ven2["
item_name
"];?>"
><?php
echo
$ven2
[
"item_name"
];?></td>
065.
<td><center><input type=
"checkbox"
><input type=
"hidden"
name=
"dataset[]"
value=
"0"
></center></td>
066.
</tr>
067.
<?php
068.
}
069.
?>
070.
</tbody>
071.
</table>
072.
</div>
073.
<div align=
"center"
>
074.
<input type=
"submit"
name=
"submit"
value=
"Submit"
>
075.
<input type=button onClick=
'window.history.back()'
value=
'Cancel'
>
076.
</div>
077.
</form>
078.
<script>
079.
$(document).ready(
function
() {
080.
$(
'#myTable'
).DataTable();
081.
} );
082.
083.
</script>
084.
<?php
085.
086.
if
(isset(
$_POST
[submit]))
087.
088.
{
089.
if
(
$dataset
== 1){
090.
foreach
(
$_POST
[
'txtID'
]
as
$i
=>
$txtID
){
091.
092.
$txtACC
=
$_POST
[
'txtACC'
][
$i
];
093.
$txtITM
=
$_POST
[
'txtITM'
][
$i
];
094.
095.
$serverName
=
"localhost"
;
096.
$userName
=
"root"
;
097.
$userPassword
=
"1234"
;
098.
$dbName
=
"purchasenewtest"
;
099.
100.
$conn
= mysqli_connect(
$serverName
,
$userName
,
$userPassword
,
$dbName
);
101.
mysqli_set_charset(
$conn
,
'utf8'
);
102.
103.
$sql
=
"insert into r (id , accountcode , orders ) values ( '$txtID','$txtACC','$txtITM' )"
;
104.
105.
$query
= mysqli_query(
$conn
,
$sql
);
106.
107.
}
108.
}
109.
}
110.
111.
?>
112.
113.
</body>
114.
</html>