Jump to content

ztimer

Members
  • Posts

    64
  • Joined

  • Last visited

Everything posted by ztimer

  1. Wow. It worked out of box. Thanks. I did not realize to use "this" and not to call it again .. Lesson learned. First use class and then use this You can't believe how happy this made me. I can continue now with the code. Thanks for this..
  2. Yes I get alert with different value for each entry.
  3. I have trouble calling timepicker with class and passing data-values to the script. So what i have so far is one loop that for each entry it will create foreach($data as $value){ $min_hour = $value['minhour']; // returns value from DB like 7 to 12 echo '<td><input type="text" value="" class="schedule-timepicker" data-minhour="'.$min_hour.'" data-minminutes="30" data-maxhour="17" data-maxminutes="00"></td>'; } Then in js file I have $(document).ready(function(){ $('.schedule-timepicker').timepicker({ timeFormat: 'HH:mm:ss', minDate: new Date(1, 1, 1, $('.schedule-timepicker').data('minhour'), 00), maxDate: new Date(1, 1, 1, $('.schedule-timepicker').data('maxhour'), 00), }); }); Problem is that the timepicker is called out and works but every input has the same minimum hours value as the first one. Please help how to resolve this. Thanks.
  4. I got it working. Did all the things mentioned here and still multiple entries. So I went crazy and started chopping out code "includes" like header sidebar and footer and still multiple entries. Then I went to the actual main.php file and on top there was include 'modules/topbar.php'; Took that away and all was well. It had only the code below inside. As Im using a template to build it on i have not yet managed to get to that part but What is making insert to make two or three entris in this part of the code. At the moment I removed Search , tasks and messages and now the code works and does not loop or request twice. <!-- START X-NAVIGATION VERTICAL --> <ul class="x-navigation x-navigation-horizontal x-navigation-panel"> <!-- TOGGLE NAVIGATION --> <li class="xn-icon-button"> <a href="#" class="x-navigation-minimize"><span class="fa fa-dedent"></span></a> </li> <!-- END TOGGLE NAVIGATION --> <!-- SEARCH --> <li class="xn-search"> <form role="form"> <input type="text" name="search" placeholder="Search..."/> </form> </li> <!-- END SEARCH --> <!-- SIGN OUT --> <li class="xn-icon-button pull-right"> <a href="#" class="mb-control" data-box="#mb-signout"><span class="fa fa-sign-out"></span></a> </li> <!-- END SIGN OUT --> <!-- MESSAGES --> <li class="xn-icon-button pull-right"> <a href="#"><span class="fa fa-comments"></span></a> <div class="informer informer-danger">4</div> <div class="panel panel-primary animated zoomIn xn-drop-left xn-panel-dragging"> <div class="panel-heading"> <h3 class="panel-title"><span class="fa fa-comments"></span> Messages</h3> <div class="pull-right"> <span class="label label-danger">4 new</span> </div> </div> <div class="panel-body list-group list-group-contacts scroll" style="height: 200px;"> <a href="#" class="list-group-item"> <div class="list-group-status status-online"></div> <img src="#" class="pull-left" alt="John Doe"/> <span class="contacts-title">John Doe</span> <p>Praesent placerat tellus id augue condimentum</p> </a> <a href="#" class="list-group-item"> <div class="list-group-status status-away"></div> <img src="#" class="pull-left" alt="Dmitry Ivaniuk"/> <span class="contacts-title">Dmitry Ivaniuk</span> <p>Donec risus sapien, sagittis et magna quis</p> </a> <a href="#" class="list-group-item"> <div class="list-group-status status-away"></div> <img src="#" class="pull-left" alt="Nadia Ali"/> <span class="contacts-title">Nadia Ali</span> <p>Mauris vel eros ut nunc rhoncus cursus sed</p> </a> <a href="#" class="list-group-item"> <div class="list-group-status status-offline"></div> <img src="#" class="pull-left" alt="Darth Vader"/> <span class="contacts-title">Darth Vader</span> <p>I want my money back!</p> </a> </div> <div class="panel-footer text-center"> <a href="pages-messages.html">Show all messages</a> </div> </div> </li> <!-- END MESSAGES --> <!-- TASKS --> <li class="xn-icon-button pull-right"> <a href="#"><span class="fa fa-tasks"></span></a> <div class="informer informer-warning">3</div> <div class="panel panel-primary animated zoomIn xn-drop-left xn-panel-dragging"> <div class="panel-heading"> <h3 class="panel-title"><span class="fa fa-tasks"></span> Tasks</h3> <div class="pull-right"> <span class="label label-warning">3 active</span> </div> </div> <div class="panel-body list-group scroll" style="height: 200px;"> <a class="list-group-item" href="#"> <strong>Phasellus augue arcu, elementum</strong> <div class="progress progress-small progress-striped active"> <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" style="width: 50%;">50%</div> </div> <small class="text-muted">John Doe, 25 Sep 2014 / 50%</small> </a> <a class="list-group-item" href="#"> <strong>Aenean ac cursus</strong> <div class="progress progress-small progress-striped active"> <div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="80" aria-valuemin="0" aria-valuemax="100" style="width: 80%;">80%</div> </div> <small class="text-muted">Dmitry Ivaniuk, 24 Sep 2014 / 80%</small> </a> <a class="list-group-item" href="#"> <strong>Lorem ipsum dolor</strong> <div class="progress progress-small progress-striped active"> <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="95" aria-valuemin="0" aria-valuemax="100" style="width: 95%;">95%</div> </div> <small class="text-muted">John Doe, 23 Sep 2014 / 95%</small> </a> <a class="list-group-item" href="#"> <strong>Cras suscipit ac quam at tincidunt.</strong> <div class="progress progress-small"> <div class="progress-bar" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%;">100%</div> </div> <small class="text-muted">John Doe, 21 Sep 2014 /</small><small class="text-success"> Done</small> </a> </div> <div class="panel-footer text-center"> <a href="pages-tasks.html">Show all tasks</a> </div> </div> </li> <!-- END TASKS --> </ul> <!-- END X-NAVIGATION VERTICAL -->
  5. Ok so i set my index to if(__FILE__ == $_SERVER['SCRIPT_FILENAME']) exit('Restricted!'); include 'config/config.inc.php'; session_start(); if(!isset($_SESSION['Username'])){ header("Location: login.php"); return; //or exit(), or die() } include 'modules/header.php'; ini_set('display_errors',1); ini_set('display_startup_errors',1); error_reporting(-1); if(isset($_GET['app'])){ if(!@include('modules/'.$_GET['app']."/main.php")){ include 'modules/error.php'; } }else{ include 'modules/main.php'; } include 'modules/footer.php'; Now i have 3 same entries .. not two. any ideas.
  6. Ok. Sorry I lost you there can you be more specific. Code example or something . Thanks. Im clearly not at the level you are on yet. Still learning new tricks. How could i fix this. I would really love to leave my index base layout like it is. It seems promising to me.. And I really appreciate your help.
  7. Noooooooo..... Ok its too late to debug this today but yes. I just made a test.php to the root of the web dir and yes. it does insert one entry. Thanks for this .. Seems it is indeed in the coding but now lets talks some more. I have the index page buidup like if(__FILE__ == $_SERVER['SCRIPT_FILENAME']) exit('Restricted!'); include 'config/config.inc.php'; session_start(); if(!isset($_SESSION['Username'])){ header("Location: login.php"); } include 'modules/header.php'; ini_set('display_errors',1); ini_set('display_startup_errors',1); error_reporting(-1); if(isset($_GET['app'])){ if(!@include('modules/'.$_GET['app']."/main.php")){ include 'modules/error.php'; } }else{ include 'modules/main.php'; } include 'modules/footer.php'; and the page that was tested is in modules and main.php requested as http://address?app=test how to prevent this of happening. If you are still willing.. Well im happy to get at least some lead for tomorrow so thanks for this @mac_gyver but if you have some fix for me i would love to read and continue from there tomorrow.. Thanks again for pointing to the right direction.
  8. Ok so this made me suspicious and I am desperate so I went to the logs and deleted them all. Made one try to load the page and one request is loged. Sorry .. This is not the case. Ps. Did try just in case with multiple browsers also. Same thing.
  9. I don't believe this. This has never happened in my history of code before. But no. I have not checked this .. It is not probable. Sorry
  10. Hi all, Its been a long time since last help request from real professional from here but I'm again in trouble with a much more spectacular plan I'm working on. For those who are interested in the plan then here it is: My Idea was to make a new build starting from scratch and make it as dynamical as possible. So my goal is not to make almost anything fixed in the code. I have made a decision to make a one supper large table for multiple different entries so no more joining and no more views for me.! In this help request I'm having trouble with Posting values to a page processing page lets call it record_changer.php The sole purpose of this file is to get form posts and decide what to do. Either update, delete, or insert. record_changer.php <?php include '../../config/config.inc.php'; if(is_ajax()){ # Checks if action value exists if(isset($_POST["action"]) && !empty($_POST["action"])){ $action = $_POST["action"]; # Switch case for value of action switch($action){ case "insert": datatable_insert_function(); break; case "update": datatable_update_function(); break; case "delete": datatable_delete_function(); break; } } } # Function to check if the request is an AJAX request function is_ajax(){ return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'; } function datatable_insert_function(){ } function datatable_update_function(){ } function datatable_delete_function(){ } ?> The problem. The problem is that the $insert places two entries to the DB. I cant seem to understand why.? # Test _POST values $_POST['UserID'] = '2'; $_POST['WorkID'] = '22'; $_POST['Status'] = '1'; $_POST['Code'] = '1'; $_POST['Title'] = '1'; $columns = array(); foreach(array_keys($_POST) as $name){ # Exclude Action and ID if($name == 'Action' || $name == 'ID' || $name == 'submit' ){ continue; } $columns[] = $name; } print_r($columns); echo "<br>"; $data = array_fill_keys($columns, 'NULL'); print_r($data); foreach($data as $key => $value){ $data[$key] = empty($_POST[$key]) ? 'NULL' : "'".mysql_real_escape_string($_POST[$key])."'"; } echo "<br>"; print_r($data); $insert = mysql_query('INSERT INTO datatable (ID, '.implode(', ',$columns).')VALUES (null, '.implode(',',$data).')') or die(mysql_error()); No errors no nothing. Just two entries of correct data. PS. Sorry for a lot of prints in the code it is work and idea in the progress. The posts at the moment are fixed in the code so it is easier to refresh and debug. Please help if you spot the problem. Im really out of ideas. Some fresh eyes might make a difference. And Please for those who want to say it is a bad idea and why and why and so on.. Move a long.!!! Im not interested in whinging i have a great use for this and just having trouble with the two entries. Thanks.
  11. Seems i have found a solution for my problem. Just for others to see if they have similar issue. (function(){ var X23ds2a = document.getElementById('video_info'); videojs("video").ready(function(){ var myPlayer = this; myPlayer.on("play", function(){ var user_id = X23ds2a.getAttribute('data-user_id'); alert("Text: " + user_id + " ."); }); }); })(jQuery);
  12. Hi. I'm in the need of some help. Cant figure out what is wrong with the code. Getting undefined all the time. The idea is to pass current playing video and user data to javascript using data-value="valuehere" and then let javascript to send the data to db with the current time and so on. I had a working solution but wanted to use videojs player and now im stuck. The code before was: (function(a){ a(".history").on("click",function(){ var b=a(this).data("mp4"); var store_type=a(this).data("store_type"); var store_title=a(this).data("store_title"); var store_tmdbid=a(this).data("store_tmdbid"); var subtitle=a(this).data("subtitle"); var resume=a(this).data("resume"); var user_id=a(this).data("user_id"); var playpath=a(this).data("mp4")+a(this).data("resume"); a(".yt-modal-box").append('<div class="modal fade" id="yt-modal"><div class="modal-dialog"><div class="modal-body flex-video widescreen"></div></div></div>'); a("#yt-modal").modal(); a("#yt-modal").find(".modal-body").html('<button type="button" class="modal-close" data-dismiss="modal" aria-hidden="true"></button><div id="video_container"><video width="100%" controls autoplay id="video"><source src="'+playpath+'" type="video/mp4"><track kind="subtitles" src="files/Movies/Subtitles/'+subtitle+'" srclang="et" />Your browser does not support the video tag.</video></div>'); a(document).on("hide.bs.modal",function(){ clearInterval(refreshId); a(".modal-body").html("")}) function updater(){ $.post("modules/api/unfinished/update.php",{ unban: "none", user_id: user_id, filename: b, store_type: store_type, store_title: store_title, store_tmdbid: store_tmdbid, lenght: video.duration, position: video.currentTime, }) .done(function(data){ if(data == 1){ $.post("assets/api/unfinished/update.php",{ unban: "unban", user_id: user_id, filename: b, lenght: video.duration, position: video.currentTime, }) function redirect(){ window.location = 'logout.php' } setTimeout(redirect, 2000); } }); } var refreshId = setInterval(updater, 5000); }) })(jQuery); Now i have something like this: <video id="example_video_1" class="video-js vjs-default-skin vjs-big-play-centered history" controls preload="auto" width="100%" height="389" data-resume="123" data-setup="{}" > var myValue; (function(a){ a(".history").ready(function(){ myValue=a(this).data("resume"); }) videojs("example_video_1").ready(function(){ var myPlayer = this; myPlayer.on("play", function(){ alert(window.myValue); // I would like to use the myValue under this. }); //myPlayer.play(); }); })(jQuery); If you have something then please help out. Thanks.
  13. What more plan do you need. ?? I have explained like in detailed the step by step what my intentions are. Do you really need that i make a drawing for you from the data i have and the output i would like. I only needed how to use the array results after the grouping and i do see that jazzman1 can see or read what i asked for help with.Dont get me wrong .. i am thankful that you read this thread and found the time to reply and im really trying my best to give all the info i know how to give to get help. I mean no disrispect and am really glad of all of your help.
  14. ups. $sql="SELECT * FROM datatable WHERE user_id = '".$_REQUEST['selected_user_id']."' AND date BETWEEN '".$_REQUEST['date_start']."' AND '".$_REQUEST['date_stop']."' ORDER BY date ASC, type ASC"; $result = mysql_query($sql); while($array = mysql_fetch_array($result)){ $data[$array['date']][$array['id']] = array($array['type'], $array['id'], $array['form_id'], $array['reserv'], $array['code'], $array['title'], $array['work_id'], $array['user_id'], $array['confirmer'], $array['form_type'], $array['form_type'], $array['child_name'], $array['child_id_code'], $array['comment'], $array['group_id'], $array['date'], $array['day'], $array['end_date'], $array['start'], $array['stop'], $array['duration'], $array['year'], $array['month'], $array['status'], $array['holiday'], $array['payment_type'], $array['days'], $array['entry_date_time']); } while($array = mysql_fetch_array($result)){ $data[$array['date']][$array['id']] = array($array['type'], $array['form_id'], $array['reserv'], $array['user_id']); } function call_back_func($value,$key){ echo "The key $key has the value:"; foreach ($value as $v) { echo '<pre>'.print_r($v,true).'</pre>'; } } array_walk($data,"call_back_func"); The key 2014-03-03 has the value: Array ( [0] => schedule [1] => 44496 [2] => [3] => [4] => [5] => [6] => 6 [7] => 141 [8] => [9] => [10] => [11] => [12] => [13] => [14] => [15] => 2014-03-03 [16] => [17] => [18] => 08:10:00 [19] => 12:40:00 [20] => 4.5 [21] => [22] => [23] => [24] => [25] => [26] => [27] => 2014-02-26 09:11:39 ) Array ( [0] => timeclock [1] => 22862 [2] => [3] => [4] => [5] => [6] => [7] => 141 [8] => [9] => [10] => [11] => [12] => [13] => [14] => 1 [15] => 2014-03-03 [16] => [17] => [18] => 08:31:06 [19] => 12:42:44 [20] => 15098 [21] => [22] => [23] => 0 [24] => [25] => [26] => [27] => ) Array ( [0] => timeflow [1] => 103489 [2] => [3] => [4] => [5] => [6] => 25 [7] => 141 [8] => [9] => [10] => [11] => [12] => [13] => [14] => [15] => 2014-03-03 [16] => [17] => [18] => 08:36:22 [19] => 08:42:57 [20] => 0.11 [21] => [22] => [23] => 0 [24] => [25] => [26] => [27] => ) Array ( [0] => timeflow [1] => 103497 [2] => [3] => [4] => [5] => [6] => 14 [7] => 141 [8] => [9] => [10] => [11] => [12] => [13] => [14] => [15] => 2014-03-03 [16] => [17] => [18] => 08:43:00 [19] => 09:00:37 [20] => 0.294 [21] => [22] => [23] => 0 [24] => [25] => [26] => [27] => ) Array ( [0] => timeflow [1] => 103501 [2] => [3] => [4] => [5] => [6] => 25 [7] => 141 [8] => [9] => [10] => [11] => [12] => [13] => [14] => [15] => 2014-03-03 [16] => [17] => [18] => 09:00:41 [19] => 09:39:59 [20] => 0.655 [21] => [22] => [23] => 0 [24] => [25] => [26] => [27] => ) Array ( [0] => timeflow [1] => 103507 [2] => [3] => [4] => [5] => [6] => 6 [7] => 141 [8] => [9] => [10] => [11] => [12] => [13] => [14] => [15] => 2014-03-03 [16] => [17] => [18] => 09:40:00 [19] => 10:00:52 [20] => 0.348 [21] => [22] => [23] => 0 [24] => [25] => [26] => [27] => ) Array ( [0] => timeflow [1] => 103519 [2] => [3] => [4] => [5] => [6] => 24 [7] => 141 [8] => [9] => [10] => [11] => [12] => [13] => [14] => [15] => 2014-03-03 [16] => [17] => [18] => 10:00:57 [19] => 11:21:02 [20] => 1.335 [21] => [22] => [23] => 0 [24] => [25] => [26] => [27] => ) Array ( [0] => timeflow [1] => 103541 [2] => [3] => [4] => [5] => [6] => 32 [7] => 141 [8] => [9] => [10] => [11] => [12] => [13] => [14] => [15] => 2014-03-03 [16] => [17] => [18] => 11:21:07 [19] => 11:38:59 [20] => 0.298 [21] => [22] => [23] => 0 [24] => [25] => [26] => [27] => ) Array ( [0] => timeflow [1] => 103554 [2] => [3] => [4] => [5] => [6] => 1 [7] => 141 [8] => [9] => [10] => [11] => [12] => [13] => [14] => [15] => 2014-03-03 [16] => [17] => [18] => 11:39:05 [19] => 11:39:17 [20] => 0.003 [21] => [22] => [23] => 0 [24] => [25] => [26] => [27] => ) Array ( [0] => timeflow [1] => 103555 [2] => [3] => [4] => [5] => [6] => 23 [7] => 141 [8] => [9] => [10] => [11] => [12] => [13] => [14] => [15] => 2014-03-03 [16] => [17] => [18] => 11:39:26 [19] => 11:47:02 [20] => 0.127 [21] => [22] => [23] => 0 [24] => [25] => [26] => [27] => ) Array ( [0] => timeflow [1] => 103561 [2] => [3] => [4] => [5] => [6] => 6 [7] => 141 [8] => [9] => [10] => [11] => [12] => [13] => [14] => [15] => 2014-03-03 [16] => [17] => [18] => 11:47:06 [19] => 12:41:07 [20] => 0.9 [21] => [22] => [23] => 0 [24] => [25] => [26] => [27] => ) The key 2014-03-04 has the value: Array ( [0] => schedule [1] => 44497 [2] => [3] => [4] => [5] => [6] => 6 [7] => 141 [8] => [9] => [10] => [11] => [12] => [13] => [14] => [15] => 2014-03-04 [16] => [17] => [18] => 08:10:00 [19] => 16:25:00 [20] => 7.75 [21] => [22] => [23] => [24] => [25] => [26] => [27] => 2014-02-26 09:11:39 ) Array ( [0] => timeclock [1] => 22876 [2] => [3] => [4] => [5] => [6] => [7] => 141 [8] => [9] => [10] => [11] => [12] => [13] => [14] => 1 [15] => 2014-03-04 [16] => [17] => [18] => 07:59:21 [19] => 16:43:49 [20] => 31468 [21] => [22] => [23] => 0 [24] => [25] => [26] => [27] => ) Array ( [0] => timeflow [1] => 103687 [2] => [3] => [4] => [5] => [6] => 25 [7] => 141 [8] => [9] => [10] => [11] => [12] => [13] => [14] => [15] => 2014-03-04 [16] => [17] => [18] => 11:17:29 [19] => 11:22:21 [20] => 0.081 [21] => [22] => [23] => 0 [24] => [25] => [26] => [27] => ) Array ( [0] => timeflow [1] => 103690 [2] => [3] => [4] => [5] => [6] => 6 [7] => 141 [8] => [9] => [10] => [11] => [12] => [13] => [14] => [15] => 2014-03-04 [16] => [17] => [18] => 11:22:24 [19] => 11:25:47 [20] => 0.056 [21] => [22] => [23] => 0 [24] => [25] => [26] => [27] => )
  15. i get the resutts in a way The key 2014-04-01 has the value: Array ( [0] => timeclock [1] => [2] => [3] => [4] => [5] => [6] => 2 [7] => [8] => [9] => [10] => [11] => [12] => [13] => 1 [14] => 2014-04-01 [15] => [16] => [17] => 08:28:37 [18] => 17:09:50 [19] => 31273 [20] => [21] => [22] => 0 [23] => [24] => [25] => [26] => ) The key 2014-04-02 has the value: Array ( [0] => timeclock [1] => [2] => [3] => [4] => [5] => [6] => 2 [7] => [8] => [9] => [10] => [11] => [12] => [13] => 1 [14] => 2014-04-02 [15] => [16] => [17] => 08:25:50 [18] => 17:06:04 [19] => 31214 [20] => [21] => [22] => 0 [23] => [24] => [25] => [26] => ) The key 2014-04-03 has the value: Array ( [0] => timeclock [1] => [2] => [3] => [4] => [5] => [6] => 2 [7] => [8] => [9] => [10] => [11] => [12] => [13] => 1 [14] => 2014-04-03 [15] => [16] => [17] => 08:26:39 [18] => 17:02:48 [19] => 30969 [20] => [21] => [22] => 0 [23] => [24] => [25] => [26] => ) The key 2014-04-04 has the value: Array ( [0] => timeclock [1] => [2] => [3] => [4] => [5] => [6] => 2 [7] => [8] => [9] => [10] => [11] => [12] => [13] => 1 [14] => 2014-04-04 [15] => [16] => [17] => 08:24:57 [18] => 16:51:09 [19] => 30372 [20] => [21] => [22] => 0 [23] => [24] => [25] => [26] => ) The key 2014-04-07 has the value: Array ( [0] => timeclock [1] => [2] => [3] => [4] => [5] => [6] => 2 [7] => [8] => [9] => [10] => [11] => [12] => [13] => 1 [14] => 2014-04-07 [15] => [16] => [17] => 08:25:23 [18] => 17:08:09 [19] => 31366 [20] => [21] => [22] => 0 [23] => [24] => [25] => [26] => ) The key 2014-04-08 has the value: Array ( [0] => timeclock [1] => [2] => [3] => [4] => [5] => [6] => 2 [7] => [8] => [9] => [10] => [11] => [12] => [13] => 1 [14] => 2014-04-08 [15] => [16] => [17] => 08:26:50 [18] => 17:07:52 [19] => 31262 [20] => [21] => [22] => 0 [23] => [24] => [25] => [26] => ) The key 2014-04-09 has the value: Array ( [0] => timeclock [1] => [2] => [3] => [4] => [5] => [6] => 2 [7] => [8] => [9] => [10] => [11] => [12] => [13] => 1 [14] => 2014-04-09 [15] => [16] => [17] => 08:24:59 [18] => 17:01:23 [19] => 30984 [20] => [21] => [22] => 0 [23] => [24] => [25] => [26] => )
  16. As i see it by the code i think jazzman1 solution is so far the closest i need to go on. The only thing now is how i can use this ..? The code at the moment $sql="SELECT * FROM datatable WHERE user_id = '".$_REQUEST['selected_user_id']."' AND date BETWEEN '".$_REQUEST['date_start']."' AND '".$_REQUEST['date_stop']."' ORDER BY date ASC, type ASC"; $result = mysql_query($sql); while($array = mysql_fetch_array($result)){ $data[$array['date']][$array['id']] = array($array['type'], $array['form_id'], $array['reserv'], $array['code'], $array['title'], $array['work_id'], $array['user_id'], $array['confirmer'], $array['form_type'], $array['form_type'], $array['child_name'], $array['child_id_code'], $array['comment'], $array['group_id'], $array['date'], $array['day'], $array['end_date'], $array['start'], $array['stop'], $array['duration'], $array['year'], $array['month'], $array['status'], $array['holiday'], $array['payment_type'], $array['days'], $array['entry_date_time']); } echo '<pre>'.print_r($data, true).'</pre>'; The output at the moment is Array ( [2014-04-01] => Array ( [23520] => Array ( [0] => timeclock [1] => [2] => [3] => 2 ) ) [2014-04-02] => Array ( [23554] => Array ( [0] => timeclock [1] => [2] => [3] => 2 ) ) [2014-04-03] => Array ( [23590] => Array ( [0] => timeclock [1] => [2] => [3] => 2 ) ) [2014-04-04] => Array ( [23627] => Array ( [0] => timeclock [1] => [2] => [3] => 2 ) ) [2014-04-07] => Array ( [23665] => Array ( [0] => timeclock [1] => [2] => [3] => 2 ) ) [2014-04-08] => Array ( [23689] => Array ( [0] => timeclock [1] => [2] => [3] => 2 ) ) [2014-04-09] => Array ( [23724] => Array ( [0] => timeclock [1] => [2] => [3] => 2 ) ) ) I now require a help on getting somethig like this.: foreach($data as $date => $value){ echo $date."<br>"; foreach(.....){ <-where the date is the $date $work_id = $array[the value of work id 0 where date = $date ]; $other values defined before. same way as before; and so on... i could make $sum_something += $duration; } echo $sum_something; <-inside of <tr></tr>; }
  17. Thank you for your help but this is not what i was looking for. Pleas read my post that i reply d before, after your posting.
  18. The intended result should be used as a time management output. The table consist of multiple entries like if a worker makes a vacation request then a entry with a date for every date he/she is on vacation is added with type = vacation, if worker enters a time entry in the office the time start and time stop is entered with duration and if worker is on sick leave the dates with type sickleave is added. Now this is the table layout for short. What i would like is to get the worker to see his/her month data in table with sum for evey day. Lets say 01.01.2014 the worker has put her self to work for 5 hours but she only worked for 4,4 hours then overoll would be -0.6 so the worker knows she must do some overtime the next day. I need to get a array to give me a variable as date and after that i must have every table value as a variable $value that i could use as $value += $array[blablabla]; so at the next date it could stop and i could display the value. With all the sums i could do a total calculations in the end that shows how many hours there is to work or not and so on..
  19. Sorry its clearly out of my leage. Can you explain some more.
  20. I can see that you are on the right track what i was looking for .. did try with some values and the array seems to work but im not sure how to use the array now like i intended to use. while($array = mysql_fetch_array($result)){ $data[$array['date']][$array['id']] = array($array['type'], $array['form_id'], $array['reserv'], $array['user_id']); } echo '<pre>'.print_r($data, true).'</pre>'; the result im getting is Array ( [2014-04-01] => Array ( [23520] => Array ( [0] => timeclock [1] => [2] => [3] => 2 ) ) [2014-04-02] => Array ( [23554] => Array ( [0] => timeclock [1] => [2] => [3] => 2 ) ) [2014-04-03] => Array ( [23590] => Array ( [0] => timeclock [1] => [2] => [3] => 2 ) ) [2014-04-04] => Array ( [23627] => Array ( [0] => timeclock [1] => [2] => [3] => 2 ) ) [2014-04-07] => Array ( [23665] => Array ( [0] => timeclock [1] => [2] => [3] => 2 ) ) [2014-04-08] => Array ( [23689] => Array ( [0] => timeclock [1] => [2] => [3] => 2 ) ) [2014-04-09] => Array ( [23724] => Array ( [0] => timeclock [1] => [2] => [3] => 2 ) ) ) Can you spare some more time to make a example how to get the data like so that the for each date would be fefined as $date and inside foreach would be defined the $id and so on the other values so that i could echo out like foreach(.........){ echo $date."<br>"; <- the date value foreach(date value ){ the other values i needed as echo $id."".$user_id."".$form_id."".$someother.... } } I need to do some other calculations with these values and give like a lot of ifs and whiles to them and i'm more at home if i have defined them but im not so good at it yet or i have not come here to ask help.
  21. Ok that did not crash the page but how to retreive the extra values now.?
  22. The code does not work. I think there was a typo also. Missing ] before = Eather way it did not work Page crashed..
  23. Hi. Need some help with the code. I have never done this type of grouping and need help with this one. The problem i'm facing is that i have one large table that contain multiple different things. For instance workers time log entry, vacation, sick leave, business trip and schedules. The layout is like "id, type, form_id, reserv, code, title, work_id, user_id, confirmer, confirmed_date_time, form_type, child_name, child_id_code, comment, group_id, date, day, end_date" and so on... What i would need to get is group this by date in php. Why? well so that i could count sum and do whatever with the values in php for per day.. What have I done so far: $sql="SELECT * FROM datatable WHERE user_id = '".$_REQUEST['selected_user_id']."' AND date BETWEEN '".$_REQUEST['date_start']."' AND '".$_REQUEST['date_stop']."' ORDER BY date ASC, type ASC"; $result = mysql_query($sql); while($array = mysql_fetch_array($result)){ $data[$array[date]][$array[id]] = $array[type]; } foreach($data as $date => $value){ echo $date."<br>"; foreach($value as $id => $type){ echo "id: ".$id." type: ".$type."<br>"; Would like to get all the values for each id here. } } And this is what i get. Im getting only the id and the type and i dont know how to get the whole row based on the id. 2014-03-05 id: 44498 type: schedule <- I would like to have all the "id, type, form_id, reserv, code, title, work_id, user_id, confirmer, confirmed_date_time, form_type, child_name, child_id_code, comment," and so on values. id: 22911 type: timeclock 2014-03-06 id: 44499 type: schedule id: 22948 type: timeclock 2014-03-07 id: 22979 type: timeclock 2014-03-10 id: 44500 type: schedule id: 23016 type: timeclock 2014-03-11 id: 44501 type: schedule id: 23046 type: timeclock 2014-03-12 id: 44502 type: schedule id: 26953 type: sickness 2014-03-13 id: 44503 type: schedule id: 26954 type: sickness 2014-03-14 id: 44504 type: schedule id: 26955 type: sickness 2014-03-15 id: 26956 type: sickness 2014-03-16 id: 26957 type: sickness 2014-03-17 id: 44505 type: schedule id: 26958 type: sickness 2014-03-18 id: 44506 type: schedule id: 26959 type: sickness 2014-03-19 id: 26960 type: sickness If you can spot the problem then please help out. Thanks.
  24. I have a problem figuring out how to join two tables and still get the session user id text-s also. I have two tables. 1. follow 2. tweet On the page i have $_SESSION['user_id'] - The user that is loged in for example "1". The idea is to get a table of the tweets and limit the results from the $_SESSION['user_id'] and the follow_user_id -s from the follow table. I figured i must join the two tables. This works but i cant seem to add the session user to the mix. My MYSQL query so far $sql="SELECT * FROM tweet JOIN follow ON tweet.user_id=follow_user_id WHERE follow.user_id = '".$_SESSION['user_id']."' ORDER BY date_time desc"; I have no idea how to add the text rows from tweets that have the session user_id also to the mix. Please can someone lend a hand. Thanks for your help.
  25. Both of the ways are great. Thank you all for helping out.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.