I am trying to create a page total based on options selected from checkboxes.
here is my HTML markup:
<input type="checkbox" id="option1" name="option1" value="<?= $add[0] ?>" />t1 + £<?= $add[0] ?><br />
<input type="checkbox" id="option2" name="option2" value="<?= $add[1] ?>" /t2 + £<?= $add[1] ?><br />
<input type="checkbox" id="option3" name="option3" value="<?= $add[2] ?>" />t3 + £<?= $add[2] ?><br />
<input type="checkbox" id="option4" name="option4" value="<?= $add[3] ?>" />t4 + £<?= $add[3] ?> <br />
This is my JavaScript that doesn't work:
var option1 = 0;
var option2 = 0;
var option3 = 0;
var option4 = 0;
var op = 0;
var extra = document.getElementById('extra');
$(":input").change(function()
{
option1 = $("input[name=option1]:checked").attr("value");
option2 = $("input[name=option2]:checked").attr("value");
option3 = $("input[name=option3]:checked").attr("value");
option4 = $("input[name=option4]:checked").attr("value");
op = parseInt(option1) + parseInt(option2) + parseInt(option3) + parseInt(option4) ;
extra.innerHTML = '<p>£'+op+'</p>';
});
Have I gone wrong somewhere?
I have other totals working, have removed from script so it's easier to read, just this one doesn't work!
EDITED:
<input id="option1" name="option1" value="20" type="checkbox">t1 + £20<br>
<input id="option2" name="option2" value="20" type="checkbox">t2 + £20<br>
<input id="option3" name="option3" value="20" type="checkbox">t3 + £20<br>
<input id="option4" name="option4" value="20" type="checkbox">t4 + £20 <br>
ADDED RADIO:
<input id="delivery" name="delivery" value="0" checked="checked" type="radio"> Standard (72hrs) - no addtional charges<br>
<input id="delivery" name="delivery" value="200" type="radio"> 45hrs - £200 per email templates<br>
<input id="delivery" name="delivery" value="250" type="radio"> 24hrs - £250 per email templates<br>
It would be easiest if you could select all your checkboxes together (and be sure you're not grabbing other checkboxes you don't want to grab:
<div id="checkSet">
<input type="checkbox" id="option1" name="option1" value="<?= $add[0] ?>" />t1 + £<?= $add[0] ?><br />
<input type="checkbox" id="option2" name="option2" value="<?= $add[1] ?>" /t2 + £<?= $add[1] ?><br />
<input type="checkbox" id="option3" name="option3" value="<?= $add[2] ?>" />t3 + £<?= $add[2] ?><br />
<input type="checkbox" id="option4" name="option4" value="<?= $add[3] ?>" />t4 + £<?= $add[3] ?> <br />
</div>
then select all of them, and iterate over them, summing their values:
var sum = 0;
$('#checkSet :checked').each(function(){
sum += parseInt($(this).val(), '10');
});
There is an error in your html:
<input type="checkbox" id="option2" name="option2" value="<?= $add[1] ?>" />t2 + £<?= $add[1] ?><br />
Then when you do parseInt it's always better to specify the base you are parsing:
parseInt(option1, '10')
Otherwise you might have odd problems with values like 09.
Can I see the generated HTML output? Maybe one of the values of the checkboxes is not a number and can't be parsed.
Parsing it returns NaN and this gives you a problem when you add up the values.
I used this code and works but of course could be written much better
var extra = document.getElementById('extra');
$(":input").change(function()
{
var option1;
var option2;
var option3;
var option4;
var op = 0;
option1 = $("input[name=option1]:checked").attr("value");
option2 = $("input[name=option2]:checked").attr("value");
option3 = $("input[name=option3]:checked").attr("value");
option4 = $("input[name=option4]:checked").attr("value");
if (option1){
op += parseInt(option1, '10');
}
if (option2){
op += parseInt(option2, '10');
}
if (option3){
op += parseInt(option3, '10');
}
if (option4){
op += parseInt(option4, '10');
}
if (op > 0){
extra.innerHTML = '<p>£'+op+'</p>';
}else{
extra.innerHTML = '';
}
});
Look at the fiddle here
Related
I am trying to make a Js to search & filter items in JSON
so I use many radio in the "form" , the result will be [X,X,X,X,X,X]
I will set 50tags x 3(choose), I can feel my function will be large.
What ways can I change my function to be simpler?
function myFunction() {
var elements1 = document.getElementsByName("chair"),
elements2 = document.getElementsByName("car"),
elements3 = document.getElementsByName("house"),
elements4 = document.getElementsByName("tree"),
elements5 = document.getElementsByName("flower"),
elements6 = document.getElementsByName("grass");
var i;
for (var a = "", i = elements1.length; i--;) {
if (elements1[i].checked) {
var a = elements1[i].value;
break;
}
};
for (var b = "", i = elements2.length; i--;) {
if (elements2[i].checked) {
var b = elements2[i].value;
break;
}
};
for (var c = "", i = elements3.length; i--;) {
if (elements3[i].checked) {
var c = elements3[i].value;
break;
}
};
for (var d = "", i = elements4.length; i--;) {
if (elements4[i].checked) {
var d = elements4[i].value;
break;
}
};
for (var e = "", i = elements5.length; i--;) {
if (elements5[i].checked) {
var e = elements5[i].value;
break;
}
};
for (var f = "", i = elements6.length; i--;) {
if (elements6[i].checked) {
var f = elements6[i].value;
break;
}
};
var o2 = document.getElementById("output2");
o2.value = "[" + a + "," + b + "," + c + "," + d + "," + e + "," + f + "]";
o2.innerHTML = o2.value;
}
<form><input type="radio" id="chair1" name="chair" class="chair" value="1">
<input type="radio" id="chair0" name="chair" class="chair" value="0" checked>
<input type="radio" id="chair-1" name="chair" class="chair" value="-1">
<input type="radio" id="car1" name="car" class="car" value="1">
<input type="radio" id="car0" name="car" class="car" value="0" checked>
<input type="radio" id="car-1" name="car" class="car" value="-1">
<input type="radio" id="house1" name="house" class="house" value="1">
<input type="radio" id="house0" name="house" class="house" value="0" checked>
<input type="radio" id="house-1" name="house" class="house" value="-1">
<input type="radio" id="tree1" name="tree" class="tree" value="1">
<input type="radio" id="tree0" name="tree" class="tree" value="0" checked>
<input type="radio" id="tree-1" name="tree" class="tree" value="-1">
<input type="radio" id="flower1" name="flower" class="flower" value="1">
<input type="radio" id="flower0" name="flower" class="flower" value="0" checked>
<input type="radio" id="flower-1" name="flower" class="flower" value="-1">
<input type="radio" id="grass1" name="grass" class="grass" value="1">
<input type="radio" id="grass0" name="grass" class="grass" value="0" checked>
<input type="radio" id="grass-1" name="grass" class="grass" value="-1">
<div> <input type="button" value="Search" id="filter" onclick="myFunction()" /> </div>
</form>
<div id="output2"></div>
Give the form an id, and you can refer to it as an object.
function myFunction() {
var form = document.getElementById("myForm");
var parts = [
form.chair.value,
form.car.value,
form.house.value,
form.tree.value,
form.flower.value,
form.grass.value
];
var o2 = document.getElementById("output2");
o2.innerHTML = '[' + parts.join(',') + ']';
}
And this is an even simpler solution using a FormData object. It supports an arbitrary number of named form fields without having to actually name them in the function:
function myFunction() {
var myForm = document.getElementById('myForm');
var formData = new FormData(myForm);
var parts = Array.from(formData.values());
var o2 = document.getElementById("output2");
o2.innerHTML = '[' + parts.join(',') + ']';
}
Use document.querySelector() to directly select the value of the checked radio button based on element names.
function myFunction() {
var chair = document.querySelector('input[name="chair"]:checked').value;
var car = document.querySelector('input[name="car"]:checked').value;
var house = document.querySelector('input[name="house"]:checked').value;
var tree = document.querySelector('input[name="tree"]:checked').value;
var flower = document.querySelector('input[name="flower"]:checked').value;
var grass = document.querySelector('input[name="grass"]:checked').value;
var o2 = document.getElementById("output2");
o2.value = "[" + chair + "," + car + "," + house + "," + tree + "," + flower + "," + grass + "]";
o2.innerHTML = o2.value;
}
Use arrays!
function myFunction() {
var elem_ids = [ "chair", "car", "house", "tree", "flower", "grass"];
var elems = elem_ids.map(id => document.getElementById(id));
var elems_check_values = elems.map(el => {
// el is kind of an array so
for(var i = 0; i < el.length; ++i)
if(el[i].checked)
return el[i].value;
return undefined;
}).filter(value => value == undefined) // to filter undefined values;
var output = "[" + elems_check_values.join(",") + "]";
var o2 = document.getElementById("output2");
o2.innerHTML = output
}
Your issue can be generalized to: how can I aggregate values for all fields in a given form?
The solution is a function that can be merely as long as 5 lines, and work for any amount of inputs with any type. The DOM model for <form> elements provides named keys (eg, myform.inputName) which each have a value property. For radio buttons, eg myform.tree.value will automatically provide the value of the selected radio button.
With this knowledge, you can create a function with a simple signature that takes a form HTMLElement, and an array of field names for the values that you need, like below: (hit the search button for results, and feel free to change the radio buttons).
function getFormValues(form, fields) {
var result = [];
for (var i = 0; i < fields.length; i++) {
result.push(form[fields[i]].value);
}
return result;
}
document.getElementById('filter').addEventListener('click', function(e) {
var o2 = document.getElementById("output2");
o2.innerHTML = getFormValues(document.forms[0], ['chair','car','house','tree','flower','grass']);
});
<form><input type="radio" id="chair1" name="chair" class="chair" value="1">
<input type="radio" id="chair0" name="chair" class="chair" value="0" checked>
<input type="radio" id="chair-1" name="chair" class="chair" value="-1">
<input type="radio" id="car1" name="car" class="car" value="1">
<input type="radio" id="car0" name="car" class="car" value="0" checked>
<input type="radio" id="car-1" name="car" class="car" value="-1">
<input type="radio" id="house1" name="house" class="house" value="1">
<input type="radio" id="house0" name="house" class="house" value="0" checked>
<input type="radio" id="house-1" name="house" class="house" value="-1">
<input type="radio" id="tree1" name="tree" class="tree" value="1">
<input type="radio" id="tree0" name="tree" class="tree" value="0" checked>
<input type="radio" id="tree-1" name="tree" class="tree" value="-1">
<input type="radio" id="flower1" name="flower" class="flower" value="1">
<input type="radio" id="flower0" name="flower" class="flower" value="0" checked>
<input type="radio" id="flower-1" name="flower" class="flower" value="-1">
<input type="radio" id="grass1" name="grass" class="grass" value="1">
<input type="radio" id="grass0" name="grass" class="grass" value="0" checked>
<input type="radio" id="grass-1" name="grass" class="grass" value="-1">
<div> <input type="button" value="Search" id="filter"/> </div>
</form>
<div id="output2"></div>
The thing you need to do is break the code up into reusable chunks. So make a method to get the value. That will reduce a lot of code. After than, you should look at a way to reduce how many elements you need to list. Finally, find an easy way to fetch all the values.
So below is code that does this. It uses a helper method to get the elements, find the value. Than it uses an array to know what element groups to look for. And finally it uses map to iterate over the list so you do not have to code multiple function calls.
function getSelected (radioBtnGroup) {
// get the elements for the radio button group
var elms = document.getElementsByName(radioBtnGroup)
// loop over them
for(var i=0; i<elms.length; i++) {
// if checked, return value and exit loop
if (elms[i].checked) {
return elms[i].value
}
}
// if nothing is selected, return undefined
return undefined
}
// list the groups you want to get the values for
var groups = ['rb1', 'rb2', 'rb3', 'rb4']
// call when you want to get the values
function getValues () {
// use map to get the values of the rabio button groups.
// map passes the index value as the first argument.
// code is map(function(k){return getSelected(k)})
var results = groups.map(getSelected)
//displat the results
console.log(results);
}
document.querySelector('#btn').addEventListener('click', getValues);
<form>
<fieldset>
<legend>Item 1</legend>
<label><input type="radio" name="rb1" value="1-1"> One</label>
<label><input type="radio" name="rb1" value="1-2"> Two</label>
<label><input type="radio" name="rb1" value="1-3"> Three</label>
</fieldset>
<fieldset>
<legend>Item 2</legend>
<label><input type="radio" name="rb2" value="2-1"> One</label>
<label><input type="radio" name="rb2" value="2-2"> Two</label>
<label><input type="radio" name="rb2" value="2-3"> Three</label>
</fieldset>
<fieldset>
<legend>Item 3</legend>
<label><input type="radio" name="rb3" value="3-1"> One</label>
<label><input type="radio" name="rb3" value="3-2"> Two</label>
<label><input type="radio" name="rb3" value="3-3"> Three</label>
</fieldset>
<fieldset>
<legend>Item 4</legend>
<label><input type="radio" name="rb4" value="4-1"> One</label>
<label><input type="radio" name="rb4" value="4-2"> Two</label>
<label><input type="radio" name="rb4" value="4-3"> Three</label>
</fieldset>
<button type="button" id="btn">Get Results</button>
</form>
Personally I would not store the values in an array, I would use an object with key value pairs.
var results = groups.reduce(function (obj, name) {
obj[name] = getSelected(name)
return obj
}, {});
How I get price and name of checked item?
var total = 0;
function test(item) {
if (item.checked) {
total += parseInt(item.value);
} else {
total -= parseInt(item.value);
}
//alert(total);
document.getElementById('Totalcost').innerHTML = total + " ";
}
<input type="checkbox" name="check_list[]" value="5" onClick="test(this);"><label>- Flag A</label>
<- <span class="badge">Price: 5 credits</span><br />
<input type="checkbox" name="check_list[]" value="13" onClick="test(this);"><label>- Flag B</label>
<- <span class="badge">Price: 13 credits</span><br />
<input type="checkbox" name="check_list[]" value="9" onClick="test(this);"><label>- Flag C</label>
<- <span class="badge">Price: 9 credits</span><br />
<button type="button" class="btn btn-primary">Tototal price: <span class="badge"><span id="Totalcost">0</span></span> credits</button>
Because this just get of value="..." I want show name and price with id or class
Updated
#Beytulla, this works for me.
<html>
<head>
<script>
function buttonClick(){
var total = 0;
var type = "";
for(var i=1;i<=3;i++) {
var id = "check_list" + i;
var label = "label" + i;
var badge = "badge" + i;
if (document.getElementById(id).checked!=null && document.getElementById(id).checked==true) {
total += parseInt(document.getElementById(id).value);
type += document.getElementById("label"+i).innerHTML + " : " + document.getElementById("badge"+i).innerHTML + ",";
}
}
document.getElementById('Totalcost').innerHTML = total;
document.getElementById('individual').innerHTML = type;
}
</script>
</head>
<body>
<form method="post">
<input type="checkbox" name="check_list1" id="check_list1" value="5" onClick="buttonClick(this);"><label id="label1"> Flag A</label> <span class="badge" id="badge1">Price: 5 credits</span><br />
<input type="checkbox" name="check_list2" id="check_list2" value="13" onClick="buttonClick(this);"><label id="label2"> Flag B</label> <span class="badge" id="badge2">Price: 13 credits</span><br />
<input type="checkbox" name="check_list3" id="check_list3" value="9" onClick="buttonClick(this);"><label id="label3"> Flag C</label> <span class="badge" id="badge3">Price: 9 credits</span><br />
<button type="button" class="btn btn-primary" onclick="buttonClick()">Total price:
<span class="badge"><span id="Totalcost">0</span></span> credits (<span id="individual">0</span>)</button>
</form>
</body>
</html>
Something like this:
you need to mark your label with an "id" and your input with an attribute "data-index". This is not a complete solution since you still need to deal with the uncheck action, although you can start from this example if you learn doing.
var total = 0;
function test(item) {
if (item.checked) {
var label = document.querySelector('#label'+ item.dataset.index);
total += label.innerText + " - " + parseInt(item.value) + " credits; ";
}
//alert(total);
document.getElementById('Totalcost').innerHTML = "Labels selected: " + total;
}
<input data-index="1" type="checkbox" name="check_list[]" value="5" onClick="test(this);">
<label id="label1">- Flag A</label>
<- <span class="badge">Price: 5 credits</span><br />
<input data-index="2" type="checkbox" name="check_list[]" value="13" onClick="test(this);">
<label id="label2">- Flag B</label>
<- <span class="badge">Price: 13 credits</span><br />
<input type="checkbox" data-index="3" name="check_list[]" value="9" onClick="test(this);">
<label id="label3">- Flag C</label>
<- <span class="badge">Price: 9 credits</span><br />
<button type="button" class="btn btn-primary">Tototal price: <span class="badge"><span id="Totalcost">0</span></span> credits</button>
how i get subtotal with php need to check user have subtotal credits if his have send mysql to database and delete subtotal = credits
so i try this
<script>function basket(item) {
if (item.checked) {
subtotal = subtotal + parseInt(item.value);
var basketItem = document.createElement('div');
basketItem.id = "Basket_" + item.id;
basketItem.innerHTML = "<span class='badge'>Toplam tıklama sayısı: <span class='badge' style='background-color:red;'>" + item.id + "</span> == " + item.value + " credits</span> ";
document.getElementById('Yetkiler').appendChild(basketItem);
} else {
subtotal = subtotal - parseInt(item.value);
document.getElementById('Basket_' + item.id).remove();
}
document.getElementById('subtotal').innerHTML = "<button type='button' class='btn btn-primary'>Total: <span class='badge'>" + subtotal + " credits</span>";
}
</script>
<?php
$price1 = "10";
$price2 = "20";
$price3 = "30";
how i do this
if($user['kredits'] > here subtotal){
?>
<form method="post">
<input id="150" type="checkbox" name="max_clicks" onClick="basket(this);" value="<?php echo "".$price1."";?>" />
<label for="150">150 Tık</label><- <span class="badge">Fiyat: <?php echo "".$price1."";?> kredi</span>
<br/>
<input id="400" type="checkbox" name="max_clicks" onClick="basket(this);" value="<?php echo "".$price2."";?>" />
<label for="400">400 Tık</label><- <span class="badge">Fiyat: <?php echo "".$price2."";?> credits</span>
<br/>
<input id="735" type="checkbox" name="max_clicks" onClick="basket(this);" value="<?php echo "".$price3."";?>" />
<label for="735">735 Tık</label><- <span class="badge">Fiyat: <?php echo "".$price3."";?> credits</span>
<br/>
<div id="Yetkiler"></div>
<span id="subtotal"></span>
<input class="btn btn-success" style="float:right;" type="submit" name="add_ad" value="Reklam satın al"
</form>
<?php } ?>
Please help, I failed to code the checkbox that can only checked 1 item. Any help would be appreciated. Thanks
Html
<input type="checkbox" name="<%=Name %>" onClick="return checkbox(this)" >
Javascript
function checkbox(a) {
var Count = 0;
if (a.checked)
{
Count = Count + 1;
}
if (Count == 2)
{
alert('choose One Please');
return false;
}
}
You are declaring count inside a method hence it will always be initialised to 0 when you click on check box. Hence declare count globally and maintain the count.
var NewCount = 0;// global declaration
function KeepCount(a){
if (a.checked){
NewCount = NewCount + 1;
}else{
NewCount = NewCount - 1;
}
if(NewCount>1){
alert('Pick Just One Please');
return false;
}
}
UPDATE:
Another approach if you don't want to add variable globally:
HTML
Group 1
<input type="checkbox" value="1" name="test[1][]" onclick="addClassCheck(this)"/>
<input type="checkbox" value="1" name="test[1][]" onclick="addClassCheck(this)"/>
<input type="checkbox" value="1" name="test[1][]" onclick="addClassCheck(this)"/>
<br/>
Group 2
<input type="checkbox" value="1" name="test[2][]" onclick="addClassCheck(this)"/>
<input type="checkbox" value="1" name="test[2][]" onclick="addClassCheck(this)"/>
<input type="checkbox" value="1" name="test[2][]" onclick="addClassCheck(this)"/>
JavaScript
function addClassCheck(element){
if(element.checked){
element.classList.add("marked");
}else{
element.classList.remove("marked");
}
if(document.getElementsByClassName("marked").length>1){
alert("Please select only one check box");
element.checked=false;
element.classList.remove("marked");
}
}
Fiddle demo
Group your checkboxs as
<input type="checkbox" class="radio" value="1" name="test[1][]" />
<input type="checkbox" class="radio" value="1" name="test[1][]" />
<input type="checkbox" class="radio" value="1" name="test[1][]" />
<br/>
Group 2
<input type="checkbox" class="radio" value="1" name="test[2][]" />
<input type="checkbox" class="radio" value="1" name="test[2][]" />
<input type="checkbox" class="radio" value="1" name="test[2][]" />
Query
$("input:checkbox").click(function() {
if ($(this).is(":checked")) {
var group = "input:checkbox[name='" + $(this).attr("name") + "']";
$(group).prop("checked", false);
$(this).prop("checked", true);
} else {
$(this).prop("checked", false);
}
});
DEMO
can anyone help me store the values in my inputs to excel using PHPExcel? so far i have success storing data from my table to excel...now i wanna do is store the values in my inputs to the excel..can anyone help me please.
example of the form inputs: enter image description here
i want is all the data in my form will be stored in excel....my code is not working help me please.
current code:
<?php
if (!isset($_POST['send'])) { ?>
<!DOCTYPE html>
<html>
<head>
<title>test</title>
</head>
<body>
<?php } else {
require_once 'Classes\PHPExcel\IOFactory.php';
$filename = 'file.xlsx';
$title = $_POST['title'];
mysql_connect("localhost","root","") or die ("cant connect!");
mysql_select_db("test") or die ("cant find database!");
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load($filename);
$objWorksheet = $objPHPExcel->getActiveSheet();
$objWorksheet = $objPHPExcel->setActiveSheetIndex(0);
$name1 = $_POST['name1'];
$optA1 = $_POST['optA1'];
$optB1 = $_POST['optB1'];
$optC1 = $_POST['optC1'];
$optD1 = $_POST['optD1'];
$total1 = $_POST['total1'];
$remarks1 = $_POST['remarks1'];
$name2 = $_POST['name2'];
$optA2 = $_POST['optA2'];
$optB2 = $_POST['optB2'];
$optC2 = $_POST['optC2'];
$optD2 = $_POST['optD2'];
$total2 = $_POST['total2'];
$remarks2 = $_POST['remarks2'];
$result = array(
'$name1',
'$optA1',
'$optB1',
'$optC1',
'$optD1',
'$total1',
'$remarks1'
),('$name2',
'$optA2',
'$optB2',
'$optC2',
'$optD2',
'$total2',
'$remarks2');
if(isset($_POST['send'])){
$headings = array(
'NAME',
'Gen Info. & Technical Knowledge',
'Communication Ability',
'Attitude Towards Profession',
'Appearance',
'TOTAL',
'Remarks'
);
$points = array(
' ',
'(3 pts)',
'(3 pts)',
'(2 pts)',
'(2 pts)',
'(10 pts)',
' '
);
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setAutoSize(true);
$objPHPExcel->getActiveSheet()
->getStyle('A1:I15')
->getAlignment()
->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A1:I1')->applyFromArray(
array(
'font' => array(
'bold' => true
),
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
),
'borders' => array(
'top' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN
)
),
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR,
'rotation' => 90,
'startcolor' => array(
'argb' => 'FFA0A0A0'
),
'endcolor' => array(
'argb' => 'FFFFFFFF'
)
)
)
);
$objPHPExcel->getActiveSheet()->fromArray($headings, null, 'A1');
$objPHPExcel->getActiveSheet()->fromArray($points, null, 'A2');
$row = 3;
while( $rows = mysql_fetch_row($result)){
$objPHPExcel->getActiveSheet()->fromArray($rows, null, 'A' . $row);
$row++;
}
}
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="'.$title.'.xlsx"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
}
if (!isset($_POST['send'])) { ?>
<form id="form1" name="form1" method="post" action="" >
FILE TITLE: <input name="title" type="text" id="title" />
<table>
<td><input name="name1" type="text" value="" required size="41" id="query1" /></td>
<td>
<input id="textboxid" type="radio" name="optA1" value="1" />1
<input id="textboxid" type="radio" name="optA1" value="2" />2
<input id="textboxid" type="radio" name="optA1" value="3" />3
</td>
<td>
<input id="textboxid" type="radio" name="optB1" value="1" />1
<input id="textboxid" type="radio" name="optB1" value="2" />2
<input id="textboxid" type="radio" name="optB1" value="3" />3
</td>
<td>
<input id="textboxid" type="radio" name="optC1" value="1" />1
<input id="textboxid" type="radio" name="optC1" value="2" />2
</td>
<td>
<input id="textboxid" type="radio" name="optD1" value="1" />1
<input id="textboxid" type="radio" name="optD1" value="2" />2
</td>
<td><input type="text" name="total1" size="3" /></td>
<td><input name="remarks1" type="text" value="" required size="8" /></td>
</tr>
<tr>
<td><input name="name2" type="text" value="" required size="41" id="query2" /></td>
<td>
<input id="textboxid" type="radio" name="optA2" value="1" />1
<input id="textboxid" type="radio" name="optA2" value="2" />2
<input id="textboxid" type="radio" name="optA2" value="3" />3
</td>
<td>
<input id="textboxid" type="radio" name="optB2" value="1" />1
<input id="textboxid" type="radio" name="optB2" value="2" />2
<input id="textboxid" type="radio" name="optB2" value="3" />3
</td>
<td>
<input id="textboxid" type="radio" name="optC2" value="1" />1
<input id="textboxid" type="radio" name="optC2" value="2" />2
</td>
<td>
<input id="textboxid" type="radio" name="optD2" value="1" />1
<input id="textboxid" type="radio" name="optD2" value="2" />2
</td>
<td><input type="text" name="total2" id="total2" size="3" /></td>
<td><input name="remarks2" type="text" value="" required size="8" /></td>
</tr>
</table>
<input type="submit" name="send" value="send to excel" id="send" formnovalidate />
</form>
</body>
</html>
<?php }
error:
<br />
<b>Warning</b>: mysql_fetch_row() expects parameter 1 to be resource, array given in <b>C:\xampp\htdocs\test\index.php</b> on line <b>114</b><br />
PK ܃KD%¸õºa [Content_Types].xmlÍ”]KÃ0…ïý%·Òf› "ëváôRΓ·kXš„¼Ù׿÷m»©+Žô¦¡4ç<§'ãé®2Éjgs6Ì,+Òv™³·ÅSzÇŒÂ*aœ…œíÙtr5^ì=`Bb‹9+cô÷œ£,¡˜9–¾.T"ÒkXr/äJ,ƒ[.`ck6¿?hÉ\„ø,*Âðá‘Ü }3òcÉC+¬Ù9Þ-E¤à|cÕjêŠBKPN®+’dÍuíÂO1î
`oú Ba +“µ¦Gò
±61yÜ‘{Ûy ƒçñef¤læ`©}¡û‡Në6=‹ ý,ˆ-m¥ŽÒ·.¬Þ[]ºözÌ*¡m×¢“xœGN¨Þ nNJ=YBˆúkÙ;ÙÒ8~ܵú—ÄCÛM5È›axáÚ?ýÏÌ1ú'9nþ(–"€zËÅo ïÞǼ¹À'PK ܃KD¶78é K _rels/.rels’ÍjÃ0€ï{
£{£´…1F^Ê ·2²Ðlå‡$–±½-}ûy‡±ºÒÃŽ–¥OŸ„vûyÕ;‡Ø‹Ó°.JPìŒØÞµ^ê§Õ¨˜ÈYű†3GØWw»g)åšØõ>ªqQC—’DŒ¦ã‰b!ž]þi$L”ò3´èÉÔ2nÊòÃoT¦:Z
áh· ê³ç[ØÒ4½áƒ˜·‰]ºÐyNì,Û•¹>¤>£j
-'
VÌ)‡#’÷EF^6ÚÜnô÷´8q"K‰ÐHàë>_ׄÖÿ¹¢eÆÍ<⇄áUdøvÁÅ
TŸPK ܃KDxÔÙ÷ Ó xl/_rels/workbook.xml.rels½“ÍjÃ0„ï}
±÷X¶Ó†R"çR
¹¶îim™Ø’¶?~ûª
m¦““˜;ó1BÛÝçгw±sV#‘åÀÐ*§;Û
xŸV÷À"I«eï,
1®ºÙ>c/)íDÓùÈ’‰‘à<*ƒƒŒ™óhÓMã )ÉÐr/ÕA¶ÈË<ßð0õ€êÌ“íµ€°×°zôøo×4ÂG§Þ´t!‚GûÄÏjZ$G%à—ãË%ã)íâ)ýG‡ÅÃzÑ
Œ¨_(¤ž61ÏÁÜ. óáÂ!D:ü¾QÓ1ÛÌÝ•aÊ9˜Í•aÖ¿0üì/V_PK ܃KD5‰À‰ Y docProps/app.xmlSÁnÛ0½ï+Ý9I1¬bH7ôÐb’vgN¦c¡²dˆ¬‘ôë';ˆë´Ûe:=ñ=<<’’º=4.ë0’
¾óY.2ô&”Öïñ´ûqu#2bð%¸à±G$q«¿¨M-F¶HYrðTˆš¹]II¦Æh–hŸ˜*Ä8]ã^†ª²ï‚ymг\äùW‰F_byÕŽ†âä¸êøMË`ú|ô¼;¶ÉO«omë¬NMêGkb Pqöý`Ð)9%U2Ú¢y–:WrzU[×ÉXWà•|/¨{„~f°‘´êxÕ¡á3²oij‘ýÂ>N!:ˆ<‹“ìt°k‰£þâÕˆLJŽÅNµSl¯õr$p)”c„/#î,;¤ŸÕ"ÿ%ñršxÈ &·}¾ù4ß%µø7µüÔÕ9߇DëдàÓØåˆÁÃ{투¡§vî€ñ¼—Ë¢ÚÖ±L«÷6Ô}j0º^¿®Áï±<k>ý+z>ý=_Ìòt†Çs®)ùþ)ôPK ܃KD~cJp ï docProps/core.xml}RANÃ0¼óŠÈ×*± ‚(M%#œ#B¢®Æ^ZÓĶì…ßã$mÚ Bòa×3X~ÕUô Î+£$M‰##•^/ÈÓê6¾ ‘G®%¯Œ†iÁ“eyR›ãàÁø(iŸ» D›SêÅjî“ÀÐ|3®æZ·¦–‹-_Í›ÓKŽœv‚±ÉNRŠQÒ~¸ª‚B5hô4MRzà"¸Úÿù GŽ˜µÂÖŸÔ=8²¿¼‰MÓ$ÍiO
ó§ôåþî±·+ÝE%€”…¹pÀѸò©BœCA.» +îñ>Dý¦#^µG¼ßX±36¼…òaü=ò|z}³º%e—iÌ.ãt¾bYÎX8³¾èþŸˆTëÝOÿʦg1Ëbv¾ÊÒü|žgÙŒ¥Ù½JïVPöžwe¨$xá”Å°l4¹½ÿx}86!-´qÒ—}:‡®ÛÃàem\;#?ºÉŽ–ßPK ܃KDs‘{Y³ ¦ xl/theme/theme1.xmlíYOoÛ6¿ïSº·²lÉu‚:EìØëÖ¦
·C´DK¬)Q 餾
íqÀ€aÝ°Ë€Ýv¶h]ºO“ÃÖý
{úc‹Šé6iSlCëƒ-’¿÷ŸïñQ¾|å^ÌÐ!’ò¤k9"‰Ïš„]ëÖhx¡c!©p`ÆÒµæDZW¶>¸Œ7UDb‚€<‘›¸kEJ¥›¶-}˜Æò"OIk.b¬`(B;øØÆÌn6m;Æ4±P‚càzs2¡>A£Œ¥µµ`>`ð•(™MøLø¹D"ÇS'û‘sÙgbÖµ#NÀFäž²ÃRÁB×jäËÞºl/‰˜ZC«Ñ
óOIWÓfN'Âñ’к—v–ü›ÿUÜ`0èœ%¿€},uV°î°ãô<5Pñ¸Ê»ßðn¯ñoà7z½ž·Q÷*¼»‚ï4Úîv³†w+¼·ªo»ßo×ð^…o¯à‡—6ÚnŸƒ"F“é
:‹ç22KÈ„³«FxàŨP¶¶»
úDÛk1¾ËÅ yp±¢ Ró”L°¸>ŽÇ‚âL Þ$X[)¦|¹2•ÉBÒ4U]ëãCFTO|ñô1zñôÑñý'Ç÷9~ðàøþÏ«8 uÂçßñ÷·Ÿ¢¿÷üáWf¼Ôñ¿ÿôÙo¿~i*øìëG<yôì›Ïÿü᡾-ðX‡hL$ºAŽÐ>Á6ƒ 2g£E˜Ö(pHp ¢ðÆ3®Gêλ- ˜€ÎîÖt=ˆÄLQðZ×€»œ³Fs®e²tsfIh.f:nãC“ìþ‰Ðf)ìdjbÙHMÍ=ÑÆ!IˆBÙŸb »Ciͯ»Ô\ò‰Bw(êajtɈŽ•™è*!.sluÍ7»·Q3ûrXGBB`fbIXÍâ™Â±Qc3y«È¤äÁ\ø5‡K‘ ãh)M47ż¦î5•Èö]6ëH¡èÔ„¼Ž9ב;|Úpœu¦I¤c?’SØ¢íqeT‚×3$Cp²6Ü·)QgKë[4ŒÌ$[™ SJ^ÏÇ9›`’”õ½V©cš¼¬l3
uû}Ù^À·ác§(Öëpÿýƒgɬx_¡ßWèw±B¯Ëåó¯ËU)¶õ^;g¯m¼'”±5gäºÌ‹¸ó‚!L惜hÙç§<–âj¸Pàü ®>¡*:ˆp
bœ\B(KÖ¡D)—p»°Öòί¨lÎç¼Å½ÐXíò ˜né÷Í%›|J]P+cpZaKo&Ì)€§”æxfiÞK¥Ùš7!oÎ^&8íf!6
f$Èü^0X„åÜC$#2FŽÑ§uJ·u^í5MÚFëͤ&Hº8w8ï¢ÔX‰’½šŽ,©Ðhå5=ù8íZè¹à1NŸÌJfaÒµ|UšòÊd>i°y[:µ×D¤Bª,£‚*_Z¼ŽI*ý›ž›ùá|°_W‹VÇùµ°O†–L&ÄWkfªa¹ÆgŠˆƒ(8Bc6ûôv‹ÝP GEs1¡n¹ñê™_fÁÉ×>ev`–F¸¬I-ö<^ê4õì5º¿¦)s4Å{wMÉv.4¸ ¿zA 0Êöh×âBEªPQ( qÈe^Ò"S ±ìv¦+9¬êVÁ£(ra¤öiˆ…J§"AÈž*í|3§©Ÿ¯FeYª+ÓâwL eÙÛÎì·P´¨&¥#rÜÉ Ù¦ì‡Ãÿpçã6^§=¨¹géE\èkGÁÆ›©pÆ£¶i¶¸éú¨Máš‚²/(ÜTø¬êoG|¢–%‚x¡S¦ßrr:w4ã2Vo·ªBÐi¼ýæSsvk³·ãlÏàkï家WSÔÖ.2ùhåÏ,>¾²wà~4cJïîÁ¥´¿øøØéÖ?PK ܃KD ™äÀ, K xl/sharedStrings.xmlm’ÍNÃ0„ï<…å‚uZ¤
•$UPJ"À$ÛÆ"þÁ»iéÛ×”ô¸Ÿg¼šÑÆó_Ý°xTÖ$|<Š8SÚJ™mÂ?‹Ç«Î¤©dc
$ü ÈçéYŒH,X
&¼&r3!°¬AKY&¼l¬×’Âè·Ya
#º“(š
-•á¬5꧅ܶ†Âò)OcTiLé[öúJcÑÍl†-ÍƎعÔî–PÖF•²a+c÷
T[è[r«uÛi(¤cÙ—jú¢ŒHQ[+ì^ú
Ù»·À®Ô9^šr°©XÙK~„>ü7~Yæ}t—ùS¾¾ï‡î*ž¡“eh>tˆàwÀSÖ·_\3Gx9À“Óxä«FhzrÀž%þŠp
éPK ܃KDwÀT;z É
xl/styles.xmlíVMoœ0½÷WX¾7àR5¥‘zhT5[©WkÅØÈ6ÛÝüúúƒÏMVí)í!p`æyüÞŒ±’›CËÑ”fR¤˜\Ä(eÅD“âÛüý'Œ´¡¢¢\
Hñ4¾ÉÞ%Ú9<ì ²×º£¥íhP{À:Å;cºë(ÒåZª/dÂŽÔRµÔXW5‘¶sh¥SË£MŒZÊÎÑ·yk4*e/LŠceI-ÅŒlp ²¤#{ʇ¶°µQì#lakñãOÁ'Äy¥äR!Õ)ÎóØ_´(î(g…bŒ‚ðJž¼º¼h›ã|Z–8 YÒQc#‰Ü:h°·Çæ¢÷‡èFÑ#Ù\:Úæn™d¸Q±˜³¬'z–¶b Œ4^‰3TaTA£ÀúW1v«(;ÔI͌ߣZ-Õmìn/æBŸM §æ´‡ Ñ2•)Kÿ°‹[HUÙ²ÜuŠF#Kœ¢?)6;¿{ϼÍ(Žóê”ÀùƒcøYOR.óCÂAøR¹Ú‘{ã£ióÌ#§²dÜÚË#{¨ŸS®¥^æG´ëø1—áPï¾oP¹?׋K0{Ÿ=ÇìßrÖˆM–ÐÑE;©Ø“¥w{¾Šrìz”a¥ƒ
iŒl12p0ߥ¡ã¶#¿í¶LqM¹¶MHï[™³ s‹s¨ÿ·úÉÙúK€z•òÉ™ò7Ëòɪ|òå““òÉ[ùoåÿÓò£¡.šîªåN(rßÞß»ÊlšÖ¬è7L¼Ðn-gu¨×ÿ,†öW)¨TPÓž›í¥x¶¿BÅúö
QßØ^š!ÊÛs(¾^ãOXöPK ܃KDÙ|÷5¬ xl/workbook.xmlQËn1¼÷+Ý›];¶Ñ^hÓ´úBã¤gyÅÍÑ¢ÖNòõ¥ä8Ý 9ôD‘Ž8ÃÕÙ½5b‘лFNNj)Àµ^£»mäõæâí;)()§•ñù $ÏÖoV{ï¶Þß ž_RP-÷B‚¸™‹ŽÙ§–UEmVщà¸ÓùhUâ4ÞVÄ3JS¬©¦u½¨¬B÷Ä°ŒÿÃá»[8÷í`Á¥I£K¢ÉõªC7•B…ð]YÞ÷ÞHa¥OèFÎ8õ{xQˆCø0 ÉɼžËjý¬ügì¨6=Òï§Fåxƒ°§¿øœ
Õ&ÜÁFmÉN«!ù4 â¹Jð9ú!ß'Rt)]e_
Ò¢C‹y)Ψ÷û/>â£wI™«6zcÊTn”!þž+,<aû˜ÔöW6¨‘‹š wH¸Eƒé¡‘åm «¨F2ÊŽQ¸¢º|U>áx©s\"?⥞e†ÐÓz:BÏ_EŸŽÐ§#ô¢lw\IC‡t¾q•¶ù8ÊNÓÙ|ò^–ü¬‘Ùvvx0æ#×~¸¯^_3çñZë?PK ܃KD§êçm: M xl/worksheets/sheet1.xml˜]“¢8†ï÷WPܯ~t©SÓ*BÕlÍT÷ÌÎuZ¢f ¢Nï¯ß!éݾéNÞsòæÉ! döé×1±ÎT䌧s
Û¢é–Ç,ÝÏí߃ß'¶•K’Æ$á)Ûo4·?-~›]¸xÍ”JK<äÙª`&hNÅ™ÚZLó¹}2{óíI>àMUdÇÅ‘HÕûa®Æ¸p:&C×qFÃ#aiåð þ‹ßíØ–®øöt¤©,MMˆTkÊ,ËíŬ˜á›XÌøI&,¥ß„•ŸŽG"ÞiÂ/jéöUxbûƒÔÂp1Öãb¦Ìu•,Awsû3zˆ¯SŠŒ?½ä¶%ÉË3MèVÒ¸ðÖõzáüU#%©:ç~ÙQ8ªVRœh)>ñË’'¡ª‹º.z´2.¼ôìDý;Ó%M’¹iè¿ž¨«çh¶¯`AQ3µò˜îÈ)‘jžV‹Ål[Um¾Ð3MžtQœ¶¦¨´¦&Úò$/þZG–<’_åBY,sÛL|Œ<Ûz¡¹˜¼.p{Ê%?þ,³ª5Ë·„ÞŒKK·²tkKo<;¾3ž|ØÓ«<½ÚÓÕœÎä㘸²Ä7Lw0¢)þ¸§_yúµ'r&vüaÏQå9ºy:4™à—s\yŽkÏéÀxÿ¯å°ÜOÅ.]I3Á/–(ïÊŒèG z˜ªû`«ÅÏZ-v†ò×7÷yá̆gmSe<–^#µ3–0Ãmg¬`†×ÎXÃÜÎ`†ßÎØÀŒQ;#„ãvFTfàFƤΪJÖåt;ËéÃQcøÔ('Ì#Fŗ溺:RŒ«²~?%èH1®Üæ݅׌Žë5c¨»Ž^g½æ#ûуØÆvZ6ÇiÕ[÷Ä‚žØ¦'zE(ÔŒyÝÂÂMScõÈ€ZâΉËõÄÖ=± '¶é‰…=±wî®VüÎùÍ«ôaŒ‡ÉÒ¿¿W=±uO,è‰mzb¡wEþû·Ø¨³#£jàðZSXšÂÊÖ¦˜ÂÆBSˆB‹zÜI=6©Mai
+SX›B`
SM!ß¡žtROLjSXšÂÊÖ¦˜ÂÆBSˆ&w¨§ÔS“Ú–¦°2…µ)¦°1…Тéjät¿Ò8&7P–#Ye
” ( „#‰šJ›ÿÎ+üð#À ?üð#À ?ºÇßý„\Àï~ð»€ßü.àw¿øÝ{üÝïÈüà÷ ¿ø=Àï~ð{€ß»Çßýj€0àÇ€~ø1àÇ€~øñ=þî_nä~ðû€ßü>à÷¿ø}Àï›üÃÆ×UuªÁeu¨PôçöŽ$¹ú2ã/)=¯ûù–¦D0~SÊÓ}4žœŽ©©>ñËMbiNH,ÕŽÄð-£"aéë-Ó„Jj:”jË¡<6ù·¯4nÓæ\ÜLN’,‘TÔRÆÎ\~'/ 5Ý~¤ ôSUÎKå׬8t²ö·sjp<ÓëW±Döô"öj©VBw*âÔ¯´(OeŠ¶äYÑRô…Kõ}íŠ"Ýót¹¼v*_5Ñ)³2¢Ê÷Ìþ¡Å«#Œ¦²8›ÛÕ1¾ÀDŠ#G=ôwL~çõ±PÕ¯>Ü‹ÝTNóY1Ûí¨P–_ãx}¦éíb\¹ll%5ÓO&+¾½„íSU…¨ôÅŒÇqy¦6o£šåì¥|mS5}Þìèv= ÙÙi´zH«WtêAí^³ ª[Ÿ„.þPK ܃KDÂ+ÿ ™ xl/worksheets/sheet2.xmlTÉrÛ0½÷+4¼×rÚtåLšÖMgÒI&Ks¦EÈbM* ÙM¿¾ µ:é¡'Äðhyö»2Éœ×h3q2›‹lŽJÛm&îׯ?ŠÄ“´J´‰'ðâlõjy#·ó% %L°ðµÌù°vàÁíAÐúL”Dõ"M}^B%ýk°|R «$±ë¶©ç©"SeÒ7óùû´’Úv÷?X:‡Ï˜7XjIIÜ“/uíÅj3ܸÕ2ÚÂK|SUÒ=}ƒn]ôÀÞ–€tµL‡8¥™<¨”8(2q~²87â…~b'$7w` 'P™`Mƒ\Ä]8üÖB¾ÄÃW§ÕWÃR‘k oñpæ’eág u0qä
É%öpÆ„8àWWÎXmÈ1µûÂÖQ2n\A!Cœçº^Og§"餹‚=˜Û ÉüãªÖ7ýY’Le‘º
£Ÿ‰BÏ
áæ'ã~ð}V:#Ò¾dè膦©ìs”+!myà^\lÑ\¼|ªÁq?»ñ#±´ÏZôˆ¡}ƒ+Ìw Ž«õèƆeC¸Ö†À
P÷H÷rcà9Ûƒ5/ùXÓÚiK×uàd;I< wAé89!Hná»t[n51PðÉ|öA$®}âhÖÑz'’
aÕ{eœ¶à½
:#õNÇˉš:©%Ëw§ÿ#\tš×-nY&º™
,M8Ÿóðšîq˜±ÎÔŠÊn½Ú´ë˜/Qº(À1åµR_ö`ÇÇèÖÚyšŒgzÔTòæ÷û#ÞÚ€uBt8¯½RíFñfLl6Ûì-ÜÛ<ív¸>u‚=L"”6„yÑ‚Ž½© ìÕÕ_PK ܃KDÂ+ÿ ™ xl/worksheets/sheet3.xmlTÉrÛ0½÷+4¼×rÚtåLšÖMgÒI&Ks¦EÈbM* ÙM¿¾ µ:é¡'Äðhyö»2Éœ×h3q2›‹lŽJÛm&îׯ?ŠÄ“´J´‰'ðâlõjy#·ó% %L°ðµÌù°vàÁíAÐúL”Dõ"M}^B%ýk°|R «$±ë¶©ç©"SeÒ7óùû´’Úv÷?X:‡Ï˜7XjIIÜ“/uíÅj3ܸÕ2ÚÂK|SUÒ=}ƒn]ôÀÞ–€tµL‡8¥™<¨”8(2q~²87â…~b'$7w` 'P™`Mƒ\Ä]8üÖB¾ÄÃW§ÕWÃR‘k oñpæ’eág u0qä
É%öpÆ„8àWWÎXmÈ1µûÂÖQ2n\A!Cœçº^Og§"餹‚=˜Û ÉüãªÖ7ýY’Le‘º
£Ÿ‰BÏ
áæ'ã~ð}V:#Ò¾dè膦©ìs”+!myà^\lÑ\¼|ªÁq?»ñ#±´ÏZôˆ¡}ƒ+Ìw Ž«õèƆeC¸Ö†À
P÷H÷rcà9Ûƒ5/ùXÓÚiK×uàd;I< wAé89!Hná»t[n51PðÉ|öA$®}âhÖÑz'’
aÕ{eœ¶à½
:#õNÇˉš:©%Ëw§ÿ#\tš×-nY&º™
,M8Ÿóðšîq˜±ÎÔŠÊn½Ú´ë˜/Qº(À1åµR_ö`ÇÇèÖÚyšŒgzÔTòæ÷û#ÞÚ€uBt8¯½RíFñfLl6Ûì-ÜÛ<ív¸>u‚=L"”6„yÑ‚Ž½© ìÕÕ_PK ܃KDÍKR"x # xl/worksheets/_rels/sheet1.xml.relsMŒ1! {_A¶÷#cÌq×ù £Øp+a!,1ú{)-'“™yýä¤ÞÔ$¶p˜(bW¶ÈÞÂã~ÝŸAIGÞ0&_X—Ý|£„}4b5&,Bïõ¢µ¸#e*•x˜giûÀæuE÷BOúhÌI·ÿèåPK ܃KDÍKR"x # xl/worksheets/_rels/sheet2.xml.relsMŒ1! {_A¶÷#cÌq×ù £Øp+a!,1ú{)-'“™yýä¤ÞÔ$¶p˜(bW¶ÈÞÂã~ÝŸAIGÞ0&_X—Ý|£„}4b5&,Bïõ¢µ¸#e*•x˜giûÀæuE÷BOúhÌI·ÿèåPK ܃KDÍKR"x # xl/worksheets/_rels/sheet3.xml.relsMŒ1! {_A¶÷#cÌq×ù £Øp+a!,1ú{)-'“™yýä¤ÞÔ$¶p˜(bW¶ÈÞÂã~ÝŸAIGÞ0&_X—Ý|£„}4b5&,Bïõ¢µ¸#e*•x˜giûÀæuE÷BOúhÌI·ÿèåPK ܃KD%¸õºa [Content_Types].xmlPK ܃KD¶78é K ’ _rels/.relsPK ܃KDxÔÙ÷ Ó ¤ xl/_rels/workbook.xml.relsPK ܃KD5‰À‰ Y Ó docProps/app.xmlPK ܃KD~cJp ï Š docProps/core.xmlPK ܃KDs‘{Y³ ¦ ) xl/theme/theme1.xmlPK ܃KD ™äÀ, K
xl/sharedStrings.xmlPK ܃KDwÀT;z É
k xl/styles.xmlPK ܃KDÙ|÷5¬ xl/workbook.xmlPK ܃KD§êçm: M é xl/worksheets/sheet1.xmlPK ܃KDÂ+ÿ ™ Y xl/worksheets/sheet2.xmlPK ܃KDÂ+ÿ ™ xl/worksheets/sheet3.xmlPK ܃KDÍKR"x # à xl/worksheets/_rels/sheet1.xml.relsPK ܃KDÍKR"x # | xl/worksheets/_rels/sheet2.xml.relsPK ܃KDÍKR"x # 5 xl/worksheets/_rels/sheet3.xml.relsPK ÿ î
Perhaps if you defined your array as
$result = array(
array(
$name1,
$optA1,
$optB1,
$optC1,
$optD1,
$total1,
$remarks1
),
array(
$name2,
$optA2,
$optB2,
$optC2,
$optD2,
$total2,
$remarks2
)
);
rather than as an array of string values with syntax errors
This really is basic PHP syntax, that you should be able to debug yourself
EDIT
You're also using while( $rows = mysql_fetch_row($result)){ without any database access whatsoever because you're trying to read the rows of data from the array, not from a database. Change it to:
foreach($result as $rows){
to just iterate over the array
I have a form in my app with several checkboxen. I want the result(value) of the checked checkedboxes saved into separate rows in the database, see below. The problem is that when saving, only the first one (Ma) is saved and the other ones not eventhough the are checked in the form. When MA is not checkend nothing happens at all... I use JqueryMobile/JavaScript/PhoneGap Build
Form:
<form name="test">
<label class="label_check" id="l1" for="ch1">Ma
<input class="custom" type="checkbox" name="checkgroup" id="ch1" value="Ma" />
</label>
<label class="label_check" id="l2" for="ch2">Di
<input class="custom" type="checkbox" name="checkgroup" id="ch2" value="Di" checked />
</label>
<label class="label_check" id="l3" for="ch3">Woe
<input class="custom" type="checkbox" name="checkgroup" id="ch3" value="Woe" />
</label>
<label class="label_check" id="l4" for="ch4">Do
<input class="custom" type="checkbox" name="checkgroup" id="ch4" value="Do" />
</label>
<label class="label_check" id="l5" for="ch5">Vr
<input class="custom" type="checkbox" name="checkgroup" id="ch5" value="Vr" checked />
</label>
<label class="label_check" id="l6" for="ch6">Za
<input class="custom" type="checkbox" name="checkgroup" id="ch6" value="Za" />
</label>
<label class="label_check" id="l7" for="ch7">Zo
<input class="custom" type="checkbox" name="checkgroup" id="ch7" value="Zo" />
</label>
</form>
</p>
<p>
<input type="button" name="saveData" id="btn1" value="Save" onclick="saveRecordSafety();"/>
Javascript:
function saveRecordSafety() {
//Write the record to the database
theDBbeter.transaction(insertRecordSafety, onTxErrorB, onTxSuccessB);
}
function insertRecordSafety(txb) {
var elementen = document.getElementsByName ("checkgroup");
var tmpChoise;
for (var r= 0; r < elementen.lenght; r++);
if (elementen[r].checked) {
tmpChoise = elementen[r].value;
alert(tmpChoise);
var sqlStrB = 'INSERT INTO testSafetyBeter (beter) VALUES (?)';
txb.executeSql(sqlStrB, [tmpChoise], onSqlSuccess, onSqlError);
}
}
I think the problem is because of your for loop being terminated by a semicolon:
for (var r= 0; r < elementen.lenght; r++);
Try this:
function insertRecordSafety(txb) {
var elementen = document.getElementsByName ("checkgroup");
var tmpChoise;
for (var r= 0; r < elementen.length; r++)
{
if (elementen[r].checked)
{
tmpChoise = elementen[r].value;
alert(tmpChoise);
var sqlStrB = 'INSERT INTO testSafetyBeter (beter) VALUES (?)';
txb.executeSql(sqlStrB, [tmpChoise], onSqlSuccess, onSqlError);
}
}
}
I've also spaced things out to make it easier to read.