OK - here is the crux of my frustrations. I have tried a dozen different ways to Sunday to generate an array, pass the array to block_data.php and output the array in an html table to send back to block.php.
I am failing - following is the applicable script:
from block.php
Code: Select all
<script>
/* Define variables. These variables will passed in an array for INSERT into time tables. */
var timestamp = new Date().getTime();
var user = "<?=$user?>";
var segment_date = "<?=$query_date?>";
var record_date = "<?=$record_date?>";
var unique = "'" + Math.round((timestamp / (user * 10)));
var unique_sub = unique.substr(5); /* unique_sub pulls a substring from var unique */
var block_id = user + "-" + unique_sub; /* var block_id will be used as a unique identifier for all related time records, across multiple tables */
$(document).ready(function() {
$(function () {
var pass_array = [];
$( "#selectable" ).selectable({
stop: function() {
$( ".ui-selected", this ).each(function() {
var index = $( "#selectable li" ).index( this );
segment_time = $(this).text();
if(segment_time) /* this if statement does not allow a push to occur unless there is a value in the var "index" */
{
pass_array.push(user, block_id, segment_date, segment_time, "Blocked", record_date); /* creates an array of user_id, blocked status, default date, isolated time passed through each function. */
}
});
}
});
$('#test').click(function() {
$.post("block_data.php",{bind_array:pass_array},function(data){
/* alert("Data Loaded: " + data); */
$('#hidden').html(data);
$('#hidden').css('display', 'inline');
});
/* alert(pass_array); */
alert("now");
});
});
});
</script>
from block_data.php
Code: Select all
<?php
session_start();
// include database connection file, if connection doesn't work the include file will throw an error message
include '../schedule/include/db_connect.php';
if (!empty($_POST['bind_array']))
{
$array = $_POST['bind_array'];
$user = $array[0];
$block_id=$array[1];
$seg_date=$array[2];
$seg_time=$array[3];
$status=$array[4];
$record_date=$array[5];
}
else
{
echo "not accessing data";
}
?>
<!DOCTYPE html>
<html>
<table name='timelist' border='1'>
<tr>
<th>View Time</th>
</tr>
<?php
$i= 0;
while ($i <=10){
echo "<tr>";
echo "<td style='border: 1px black solid; text-align: center; width: 100px'>". $user ."</td>";
echo "<td style='border: 1px black solid; text-align: center; width: 120px;'>". $block_id ."</td>";
echo "<td style='border: 1px black solid; text-align: center; width: 50px'>".$seg_date ."</td>";
echo "<td style='border: 1px black solid; text-align: center; width: 100px'>". $seg_time ."</td>";
echo "</tr>";
$i++;
}
echo"</table>";
?>
</html>
The long and short of it is that the table displays the same $seg_time on every single row. Originally I thought I was only passing the a partial array. However when I print array the WHOLE array is coming through to block_data.php. For some reason I can not assign variables to the elements within the pass_array.
And - just as frustrating - when I try to assign keys WITHIN the push block itself - it mucks up my code. I'm no longer able to select values period.
Celauran - this has to be very frustrating to you. But... trust me... my level of frustration with the situation passed 10 sometime ago.
Any advice you have to offer would be greatly appreciated.
Pavilion