I want to store the display value in a database as a row but only when the statement false. So I created this way to store but not sure about the declaration of each value for the column. I so confused about array and so on. I have this for loop in PHP to display in a table but not sure if this need to convert into an array.
<?php
for($x=$str, $y=0; $y!=($endmo);$x++) {
if ($w == 1){
//has code here
}
else{
//it will display value here in table
$date = $x;
$a = 8;
$b = 3;
$c = 4 ;
//it will display value here
//not sure if need to convert into array
$ts = array("$date", "$a", "$b", "$c");
$var = json_encode($ts);
}
$y++;
}
?>
The idea is I just want to store the else value statement only. This will store the same value of a, b and c but different date when rendering this and this will save in row but we will save the value for each in a different column. This is my javascript code :
<script>
$(document).ready(function(){
var mo = '<?php echo $mo; ?>';
var yr = '<?php echo $yr; ?>';
var obj = JSON.parse('<?= $var; ?>');
//how to get all the value from php above
$.ajax({
type: "POST",
dataType: "text",
data: {'date':'date', 'mo': 'mo', 'yr': yr,'a': 'a', 'b': b, 'c': c},
url: "save.php",
success: function(data) {
$('#rdft').html(data);
}
});
}
</script>
In save.php I will use the SQL statement to insert each value into the database.