Jump to content

Ryflex

Members
  • Posts

    115
  • Joined

  • Last visited

Everything posted by Ryflex

  1. Who's the fool of the day.... ME! In the original script I posted for the menu in the header there are 2 little javascripts. These scripts made the sorting possible. Made a third pointing to the child items and works like a charm.
  2. Hi, What I noticed with the .js I used and also on you're example page is that sometimes you need to have the .js in the body. Dunno why but it helped on my side
  3. I'm no master in java (more noob than whatsoever) but I checked the page you gave and it seems your missing a part of the .js (function($){ $.confirm = function(params){ if($('#confirmOverlay').length){ // A confirm is already shown on the page: return false; } var buttonHTML = ''; $.each(params.buttons,function(name,obj){ // Generating the markup for the buttons: buttonHTML += '<a href="#" class="button '+obj['class']+'">'+name+'<span></span></a>'; if(!obj.action){ obj.action = function(){}; } }); var markup = [ '<div id="confirmOverlay">', '<div id="confirmBox">', '<h1>',params.title,'</h1>', '<p>',params.message,'</p>', '<div id="confirmButtons">', buttonHTML, '</div></div></div>' ].join(''); $(markup).hide().appendTo('body').fadeIn(); var buttons = $('#confirmBox .button'), i = 0; $.each(params.buttons,function(name,obj){ buttons.eq(i++).click(function(){ // Calling the action attribute when a // click occurs, and hiding the confirm. obj.action(); $.confirm.hide(); return false; }); }); } $.confirm.hide = function(){ $('#confirmOverlay').fadeOut(function(){ $(this).remove(); }); } })(jQuery);
  4. Hi all, I'm building a menu CMS. In this CMS the menu items are sortable by using a jquery piece I found. The sorting works great but when I try to implement child items it kind of screws up. the child items can't be selected seperatly for example. Below is all my code. I hope someone can help me. Menu.php <?php include("../include/session.php"); include("include/menu_constants.php"); //check if user is logged on if(!$session->logged_in){ header("Location:../main.php"); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"[]> <html> <head> <title>Menu Factory-Nation </title> <link rel="stylesheet" href="include/1080px_18column_grid.css" type="text/css" /> <link rel="stylesheet/less" href="include/menu.less" type="text/less" /> <script src="http://lesscss.googlecode.com/files/less-1.0.18.min.js"></script> <?php/*java for sortable list*/?> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript" src="include/jquery-1.3.2.min.js"></script> <script type="text/javascript" src="include/jquery-ui-1.7.1.custom.min.js"></script> <script type="text/javascript"> // When the document is ready set up our sortable with it's inherant function(s) $(document).ready(function() { $("#level3").sortable({ handle : '.handle', update : function () { var order = $('#level3').sortable('serialize'); $("#info").load("include/process-sortable.php?"+order); } }); }); </script> <script type="text/javascript"> // When the document is ready set up our sortable with it's inherant function(s) $(document).ready(function() { $("#level9").sortable({ handle : '.handle', update : function () { var order = $('#level9').sortable('serialize'); $("#info2").load("include/process-sortable.php?"+order); } }); }); </script> </head> <body> <div class="container_18 background"> <div class="grid_3"> <nav class="menu"> <?php //query database for all level 3 parent items $sql = $database->connection->prepare("SELECT * FROM ".TBL_MENU." WHERE `userlevel` = '3' AND `parent` = '0' AND `active` = '1' ORDER by `order` ASC"); $sql->execute(); //start of list echo "<ul class='menulist'>"; //while loop to iterate the menu items while($row = $sql->fetch()) { echo "<li><a href=".$row['link'].">".$row['name']."</a>"; //check for child menu if($row['child'] == 1) { $parent = $row['id']; //query database for all level 3 child items $subsql = $database->connection->prepare("SELECT * FROM ".TBL_MENU." WHERE `userlevel` = '3' AND `child` = '2' AND `parent` = '$parent' AND `active` = '1' ORDER by `order` ASC"); $subsql->execute(); //start of child list echo "<ul class='childlist'>"; //while loop to iterate the child menu items while($subrow = $subsql->fetch()) { echo "<li><a href=".$subrow['link'].">".$subrow['name']."</a></li>"; } //end of child list echo "</ul></li>"; } else { echo "</li>"; } } //check if user is at userlevel 9. If so show all admin menu items. if($session->isUserlevel(9)) { echo "<li><br></li>"; //query database for all level 9 parent items $sql = $database->connection->prepare("SELECT * FROM ".TBL_MENU." WHERE `userlevel` = '9' AND `active` = '1' ORDER by `order` ASC"); $sql->execute(); //while loop to iterate the menu items while($row = $sql->fetch()) { echo "<li><a href=".$row['link'].">".$row['name']."</a></li>"; } } //end of list echo"</ul>" ?> </nav> </div> <div class="grid_12"> <div class="grid_12 alpha omega"> <h3>Normal menu-items</h3> <p>Here you can edit the menu for the normal users. Set userlevel to 3 to make sure all users will be able to see the items when activated.<br> Please make sure the link works before you activate the menu-items.</p> </div> <div class="grid_1 alpha"> <label class="label"><br>Move</label> </div> <div class="grid_3"> <label class="label"><br>Item name</label> </div> <div class="grid_3"> <label class="label"><br>Item link</label> </div> <div class="grid_2"> <label class="label"><br>Userlevel</label> </div> <div class="grid_2"> <label class="label">Active<br>Yes/No</label> </div> <div class="grid_1 omega"> <label class="label"><br>Delete</label> </div> <div class="clear"></div> <form name="menu-edit" action="include/process.php" method="POST"> <ul id="level3"> <?php //set $n at 1 $n = 1; //query database for all level 3 parent items $sql = $database->connection->prepare("SELECT * FROM ".TBL_MENU." WHERE `userlevel` < '9' AND `parent` = '0' ORDER by `order` ASC"); $sql->execute(); //while loop to iterate the menu items while($row = $sql->fetch()) { //set the active checked and the inactive empty if($row['active'] == "0"){$active_0 = 'checked';}else{$active_0 = '';} if($row['active'] == "1"){$active_1 = 'checked';}else{$active_1 = '';} //check if there are child items available if($row['child'] == "1") { //set some starting variables $c = 1; $id = $row['id']; $child_click = "<img src='images/folder_down.png' id='child_click' class='new_image' alt='add_new' style='width: 16px; height: 16px; overflow: hidden; display: block;'/> <img src='images/folder_up.png' id='child_reset' class='new_image' alt='add_new' style='width: 0px; height: 0px; overflow: hidden; display: block;'/>"; $child_row_1 = "<div id='child_animate' class='demoarea' style='width: 700px; height: 0px; overflow: hidden; display: block;'> <ul id='level4'>"; $child_row_3 = "</ul></div>"; //query the database for the child items $child_sql = $database->connection->prepare("SELECT * FROM ".TBL_MENU." WHERE `userlevel` < '8' AND `parent` = '$id' ORDER by `order` ASC"); $child_sql->execute(); //while loop to iterate the child items while($child_rows = $child_sql->fetch()) { //set the active checked and the inactive empty if($child_rows['active'] == "0"){$child_active_0 = 'checked';}else{$child_active_0 = '';} if($child_rows['active'] == "1"){$child_active_1 = 'checked';}else{$child_active_1 = '';} //put the form row in $child_row_2 array use $c to iterate $child_row_2[$c] = " <li id='listItem_".$child_rows['id']."'> <div class='grid_1 alpha'> <img src='images/arrow.png' alt='move' width='16' height='16' class='handle' /> </div> <div class='grid_3'> <input type='text' id='field' name='menu[".$n."][name]' value='".$child_rows['name']."' /> </div> <div class='grid_3'> <input type='text' id='field' name='menu[".$n."][link]' value='".$child_rows['link']."' /> <input type='hidden' name='menu[".$n."][id]' value='".$child_rows['id']."' /> </div> <div class='grid_2'> <input type='text' id='levelfield' name='menu[".$n."][userlevel]' value='".$child_rows['userlevel']."' /> </div> <div class='radio'> <input type='radio' name='menu[".$n."][active]' value='1' ".$child_active_1." /> <input type='radio' name='menu[".$n."][active]' value='0' ".$child_active_0." /> </div> <div class='grid_1'>&nbsp </div> <div class='grid_1 omega'> <input onclick='setId(".$child_rows['id'].")' class='delete' type='submit' name='delete' id='delete' value='".$row['id']."'></input> </div> <div class='clear'></div> </li> "; $n++; $c++; } } //if there are no child items set all child items to nothing else { $child_click = ""; $child_row_1 = ""; $child_row_2 = ""; $child_row_3 = ""; } //echo the form row echo "<li id='listItem_".$row['id']."'> <div class='grid_1 alpha'> <img src='images/arrow.png' alt='move' width='16' height='16' class='handle' /> </div> <div class='grid_3'> <input type='text' id='field' name='menu[".$n."][name]' value='".$row['name']."' /> </div> <div class='grid_3'> <input type='text' id='field' name='menu[".$n."][link]' value='".$row['link']."' /> <input type='hidden' name='menu[".$n."][id]' value='".$row['id']."' /> </div> <div class='grid_2'> <input type='text' id='levelfield' name='menu[".$n."][userlevel]' value='".$row['userlevel']."' /> </div> <div class='radio'> <input type='radio' name='menu[".$n."][active]' value='1' ".$active_1." /> <input type='radio' name='menu[".$n."][active]' value='0' ".$active_0." /> </div> <div class='grid_1' style='height:16px'> ".$child_click."&nbsp </div> <div class='grid_1 omega'> <input onclick='setId(".$row['id'].")' class='delete' type='submit' name='delete' id='delete' value='".$row['id']."'></input> </div> <div class='clear'></div> </li> ".$child_row_1." "; if($child_row_2 > ""){ foreach ($child_row_2 as $value) { echo $value; } } echo $child_row_3; $n++; } ?> <input type="hidden" name="n" value="<?php echo $n; ?>" /> </ul> </div> <div class="grid_12 push_3"> <div class="grid_12 alpha omega"> <h3>Admin menu-items</h3> <p>Here you can edit the menu for the normal users. Set userlevel to 9 to make sure all users will be able to see the items when activated.<br> Please make sure the link works before you activate the menu-items.</p> </div> <div class="grid_1 alpha"> <label class="label"><br>Move</label> </div> <div class="grid_3"> <label class="label"><br>Item name</label> </div> <div class="grid_3"> <label class="label"><br>Item link</label> </div> <div class="grid_2"> <label class="label"><br>Userlevel</label> </div> <div class="grid_2"> <label class="label">Active<br>Yes/No</label> </div> <div class="grid_1 omega"> <label class="label"><br>Delete</label> </div> <div class="grid_11 alpha"> <ul id="level9"> <?php //query database for all level 9 parent items $sql = $database->connection->prepare("SELECT * FROM ".TBL_MENU." WHERE `userlevel` = '9' AND `parent` = '0' ORDER by `order` ASC"); $sql->execute(); //while loop to iterate the menu items while($row = $sql->fetch()) { //set the active checked and the inactive empty if($row['active'] == "0"){$active_0 = 'checked';}else{$active_0 = '';} if($row['active'] == "1"){$active_1 = 'checked';}else{$active_1 = '';} //echo the form row echo "<li id='listItem_".$row['id']."'> <div class='grid_1 alpha'> <img src='images/arrow.png' alt='move' width='16' height='16' class='handle' /> </div> <div class='grid_3'> <input type='text' id='field' name='menu[".$n."][name]' value='".$row['name']."' /> </div> <div class='grid_3'> <input type='text' id='field' name='menu[".$n."][link]' value='".$row['link']."' /> <input type='hidden' name='menu[".$n."][id]' value='".$row['id']."' /> </div> <div class='grid_2'> <input type='text' id='levelfield' name='menu[".$n."][userlevel]' value='".$row['userlevel']."' /> </div> <div class='radio'> <input type='radio' name='menu[".$n."][active]' value='1' ".$active_1." /> <input type='radio' name='menu[".$n."][active]' value='0' ".$active_0." /> </div> <div class='grid_1'> &nbsp </div> <div class='grid_1 omega'> <input onclick='setId(".$row['id'].")' class='delete' type='submit' name='delete' id='delete' value='".$row['id']."'></input> </div> <div class='clear'></div> </li>"; $n++; } ?> <input type="hidden" name="n" value="<?php echo $n; ?>" /> </ul> <div class="grid_3 push_9 save_cancel alpha"> <input type="submit" name="submit" alt="submit" class="save" value="submit"/> <input type="submit" name="cancel" alt="cancel" class="cancel" value="submit"/> </div> </form> </div> <div class="clear"></div> <br> <div class="grid_11 alpha"> <div id="animate" class="demoarea" style="width: 40px; height: 38px; overflow: hidden; display: block;"> <form name="add_menu_item" action="include/process.php" method="POST"> <ul id="level3"> <li> <div class='grid_1 alpha'> <img src='images/new.png' id="click" class="new_image" alt='add_new' width='16' height='16'/> </div> <div class='grid_3'> <input type='text' id='field' name='menu_ad_name' value='' /> </div> <div class='grid_3'> <input type='text' id='field' name='menu_ad_link' value='' /> <input type='hidden' name='menu_ad_id' value='".$row['id']."' /> </div> <div class='grid_2'> <input type='text' id='levelfield' name='menu_ad_level' value='' /> </div> <div class='grid_2 omega'> <input type='radio' name='menu_add[active]' value='1' /> <input type='radio' name='menu_add[active]' value='0' /> </div> <div class='clear'></div> </li> </ul> <div class="grid_3 push_9 save_cancel alpha"> <input type="submit" name="save" alt="save" class="save" value="save"/> <input type="submit" id="reset" name="hide" alt="hide" class="cancel" value="submit"/> </div> </form> </div> </div> </div> <script type="text/javascript"> $('#click').click(function() { $("#animate").animate({ width: 700, height: 52 }, 1000); }); $('#reset').click(function() { $("#animate").animate({ width: 40, height: 38 }, 1000); }); $('#child_click').click(function() { $("#child_animate").animate({ width: 700, height: 67 }, 1000); $("#child_click").animate({ width: 0, height: 0 }, 1); $("#child_reset").animate({ width: 16, height: 16 }, 1); }); $('#child_reset').click(function() { $("#child_animate").animate({ width: 700, height: 0 }, 1000); $("#child_reset").animate({ width: 0, height: 0 }, 1); $("#child_click").animate({ width: 16, height: 16 }, 1); }); function setId(id) { document.getElementById('id').value = id; } </script> </body> </html> Process-sortable.php <?php include("../../include/session.php"); include("../include/menu_constants.php"); foreach ($_GET['listItem'] as $position => $item) : //$sql[] = "UPDATE ".TBL_MENU." SET `order` = $position WHERE `id` = $item"; //query database for all level 3 child items $sql = $database->connection->prepare("UPDATE ".TBL_MENU." SET `order` = $position WHERE `id` = $item"); $sql->execute(); endforeach; print_r ($sql); ?> CSS (LESS actually) /* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 License: none (public domain) html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}table{border-collapse:collapse;border-spacing:0}*/ body { font-family: verdana; font-size: 0.8em; h3 { font-family: inherit; margin: 10px 0px 0px 0px; } p { font-family: inherit; font-size: 10px; margin: 0px 0px 10px 0px; } input { font-family: inherit; font-size: 10px; } label { font-family: inherit; font-size: 9px; } } .background { background-image: url('images/1080px_18column_background.gif'); } .submit { text-decoration: none; border: none; background-color: #efefef; width: 100px; } .save { background: url("images/save.png") no-repeat center center; width: 48px; height:15px; border: none; color: transparent; font-size: 0; padding: 0px; } .cancel { background: url("images/cancel.png") no-repeat center center; width: 58px; height:15px; border: none; color: transparent; font-size: 0; padding: 0px; } .delete { background: url("images/delete.png") no-repeat center center; width: 16px; height:16px; border: none; color: transparent; font-size: 0; padding: 0px; } .menu { font-size: 0.8em; } #field { width: 154px; } #levelfield { width: 94px; } #level3 { list-style: none; margin: 0px 0px 0px -40px; li { display: block; padding: 5px 0px 5px 0px; margin-bottom: 3px; background-color: #efefef; width: 700px; img.handle { cursor: move; } .radio{ width: 50px; margin-left: 10px; display: inline; float: left; } } } #level4 { list-style: none; margin: 0px 0px 0px -40px; li { display: block; padding: 5px 0px 5px 0px; margin-bottom: 3px; background-color: #cfcfcf; width: 700px; img.handle { cursor: move; } .radio{ width: 50px; margin-left: 10px; display: inline; float: left; } } } #level9 { list-style: none; margin: 0px 0px 0px -40px; li { display: block; padding: 5px 0px 5px 0px; margin-bottom: 3px; background-color: #efefef; width: 700px; img.handle { cursor: move; } .radio{ width: 50px; margin-left: 10px; display: inline; float: left; } } } .handle { margin-left: 12px; margin-top: 3px; } .new_image { margin-left: 12px; margin-top: 3px; cursor: pointer; } .save_cancel { text-align: right; } /* For modern browsers */ .cf:before, .cf:after { content:""; display:table; } .cf:after { clear:both; } /* For IE 6/7 (trigger hasLayout) */ .cf { zoom:1; } .border-radius (@radius: 5px) { -moz-border-radius: @radius; -webkit-border-radius: @radius; border-radius: @radius; } .box-shadow (@x: 0, @y: 5px, @blur: 5px, @spread: -5px, @color: #000) { -moz-box-shadow: @x @y @blur @spread @color; -webkit-box-shadow: @x @y @blur @spread @color; box-shadow: @x @y @blur @spread @color; } .linear-gradient (@start: #fff, @end: #ddd, @percent: 100%) { background: @start; /* Old */ background: -moz-linear-gradient(top, @start 0%, @end @percent); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,@start), color-stop(@percent,@end)); /* Chrome, Safari 4+ */ background: -webkit-linear-gradient(top, @start 0%,@end @percent); /* Chrome 10+, Safari 5.1+ */ background: -o-linear-gradient(top, @start 0%,@end @percent); /* Opera 11.10+ */ background: -ms-linear-gradient(top, @start 0%,@end @percent); /* IE 10+ */ background: linear-gradient(top, @start 0%,@end @percent); /* W3C */ } I can't post the java code it is too much
  5. For others to use with the same problems in the future. The script that creates the form: <form name="menu-edit" action="include/process.php" method="POST"> <ul id="level3"> <?php //set $n at 1 $n = 1; //query database for all level 3 parent items $sql = $database->connection->prepare("SELECT * FROM ".TBL_MENU." WHERE `userlevel` = '3' AND `parent` = '0' ORDER by `order` ASC"); $sql->execute(); //while loop to iterate the menu items while($row = $sql->fetch()) { echo "<li id='listItem_".$row['id']."'> <img src='images/arrow.png' alt='move' width='16' height='16' class='handle' /> <input type='text' name='menu[".$n."][name]' value='".$row['name']."' /> <input type='text' name='menu[".$n."][link]' value='".$row['link']."' /> <input type='hidden' name='menu[".$n."][id]' value='".$row['id']."' /></li>"; $n++; } ?> <input type="hidden" name="n" value="<?php echo $n; ?>" /> </ul> <input type="submit" name="submit" value="Adjust" /> </form> The script that extracts the information to insert into the database: <?php if(!$_POST['submit']) { header("Location:..menu.php"); } //get the value of $n represents the number of rows $n = $_POST['n']; //loop through every row to update for($s = 1; $s < $n; $s++) { $name = $_POST['menu'][$s]['name']; $link = $_POST['menu'][$s]['link']; $id = $_POST['menu'][$s]['id']; echo "UPDATE ".TBL_MENU." SET `name` = '$name', `link` = '$link' WHERE `id` = '$id'"."<br>"; } ?> Have a good weekend!
  6. I checked on the internet and tried it with the below. It seems to work. Now I only have to make a loop to iterate trough it echo "<br>".$_POST['menu'][$s]['name'];
  7. Ok that sounds logical but how to extract the data then?
  8. Hi all, I'm trying to build a menu which can be edited in the browser and will be loaded from the server. I have created a form which loads al the menu items from the DB and gives the field an array based name. I have tried several ways to get the info out of the database but not one of them works. Also when I use print_r($_POST); it gives the information like this: Array ( [name] => Array ( [0] => Home [1] => Buildings [2] => Log-out ) [link] => Array ( [0] => home.php [1] => buildings.php [2] => ../process.php ) [n] => 4 [submit] => Adjust ) Below is the code of the form: <form name="menu-edit" action="include/process.php" method="POST"> <ul id="level3"> <?php //set $n at 1 $n = 1; //query database for all level 3 parent items $sql = $database->connection->prepare("SELECT * FROM ".TBL_MENU." WHERE `userlevel` = '3' AND `parent` = '0' ORDER by `order` ASC"); $sql->execute(); //while loop to iterate the menu items while($row = $sql->fetch()) { echo "<li id='listItem_".$row['id']."'><img src='images/arrow.png' alt='move' width='16' height='16' class='handle' /><input type='text' name='name[]' value='".$row['name']."' /><input type='text' name='link[]' value='".$row['link']."' /></li>"; $n++; } ?> <input type="hidden" name="n" value="<?php echo $n; ?>" /> </ul> <input type="submit" name="submit" value="Adjust" /> </form> Below is what I have now as process.php: <?php //check if user has admin priveleges if(!$session->isUserlevel(9)) { header("Location:../main.php"); } if(!$_POST['submit']) { header("Location:..menu.php"); } print_r($_POST); $n = $_POST['n']; $s = 1; echo "<br>".$_POST['name'.$s]; $name[] = $_POST['name']; foreach($name[] as $key => $value) { echo $key."<br>".$value."<br><br>"; } ?> Hope you can help
  9. Nevermind I found it $calls_list = array(); $i = 0; while($row = mysql_fetch_assoc($qry)) { $calls_list[$i] = array('name'=>$row['user'],'client'=>$row['klant'],'month'=>$row['maand'],'year'=>$row['jaar']); $i++; }
  10. Hi OOP This seems to work with the data you provided but here's comes the stupid question: How do I need to query the DB to get the $calls_list array that way. Ryflex
  11. My mistake the name column is the employee name. it is only one table i want to pull the info from. When a call is logged the name of the logger and the client is put in the row of the call.
  12. That sounds about right. Maybe it's easier if i kinda show what I have/want. TABLE: --------------------------------------------------- | id | name | client | day | month | year | --------------------------------------------------- Output per client ----------------------------------------------------------- | months | client 1 | client 2 | client 3 | client 4 | ----------------------------------------------------------- | jan | 20 | 5 | 100 | 55 | ----------------------------------------------------------- etc per employee ----------------------------------------------------------- | months | emplo1 | emplo2 | emplo3 | emplo4 | ----------------------------------------------------------- | jan | 10 | 85 | 75 | 35 | ----------------------------------------------------------- etc
  13. Hi all, For a logging tool I need to make some automated reports. On 1 page it needs to give for 4 clients the amount of calls per month for the last 12 months. Also it needs to give the amount of calls for the employees per month for the last 12 months. I was hoping you could help me with a better solution than seperate queries. Gr Ryflex
  14. Hi all, With only the diffine function from sunfighter I managed to get the script working. Thanks for your help Ryflex
  15. Hi all, I tried Sunfighter's function's and I'm getting weird answers. I'll post code below and the actual times //resetten van de count en compare $count = 0; $compare = -100; function differate($row_1, $row_2) { $answer = number_format((diffine($row_2) - diffine($row_1))/60); echo $answer."<BR>"; if ($answer < 30) { return '1'; } if ($answer > 60) { return '0'; } } function diffine($time) { $mine = explode(':', $time); $minetotal1 = $mine[0] * 3600 + $mine[1] * 60 + $mine[2]; return $minetotal1; } //Gegevens ophalen uit de DB van de geselecteerde maand/jaar $dataqry = mysql_query("SELECT tijd FROM `Standby` WHERE `maand` = '$maand' && `jaar` = '$jaar' ORDER BY jaar ASC, maand ASC, dag ASC, tijd ASC"); if(!$dataqry) { die("Storingen kunnen niet gevonden worden."); } while($row = mysql_fetch_assoc($dataqry)) { //$count ++; if(differate($compare, $row['tijd']) == '1') { $count++; $compare = $row['tijd']; } } echo $count."<BR>"; //echo $compare."<BR>"; } Times: 00:20:16 06:24:34 06:46:03 18:00:00 18:38:59 20:49:06 22:46:03 23:13:28 23:28:22 23:51:12 23:51:20 Edit: The value of count should be 8
  16. Hi all, Well I talked to our database specialist and he helped me format this code. Sadly he's off to home now and the code doesn't work. //reset count and compare $count = 0; $compare = -100; //Get data from DB $dataqry = mysql_query("SELECT * FROM `Standby` WHERE `maand` = '$maand' && `jaar` = '$jaar' ORDER BY jaar DESC, maand DESC, dag DESC, tijd DESC"); if(!$dataqry) { die("Storingen kunnen niet gevonden worden."); } while($row = mysql_fetch_assoc($dataqry)) { //$count ++; if(strtotime($row['tijd']) - strtotime($compare) > strtotime("00:30:00")) { $count++; echo $compare."<BR>".$row['tijd']."<BR>"; $compare = $row['tijd']; } } Is there anyone who can help me get it right Thanks Ryflex
  17. Hi all, I'm trying to make a piece of PHP that calculates the hours you can put down on your timesheet. Do do this I need to get al entries in the DB where the time between the rows is more than half an hour (I have a time field) and then count them. Example of the table Call1 | 07:12:10 Call2 | 07:15:25 Call3 | 08:00:38 The output has to be 2 because the times between Call1 and Call2 is less than half an hour but the difference between Call2 and Call3 is more than half an hour. My question to you is: Is this possible and if so can anyone give me some hints on how to get the script to work this way. Thanks all Greetz Ryflex
  18. Hi all, Well I guess I am again asking to much from php/html. I'm trying to build a message system where you can select multiple messages to delete them of you click on the subject of the message and you open the message. Current code I have: <FORM ID="Search" NAME="Search" METHOD="POST" ACTION="/berichten-exec.php"> <ul CLASS="ul-ver" VALIGN="top"> <li><a CLASS="a-ver" href="berichten-verzenden.php">Nieuw Bericht</a></li> <li><INPUT CLASS="input" TYPE="SUBMIT" NAME="verwijderen" ID="verwijderen" VALUE="verwijderen"></INPUT></li> </ul> </TD> <TD> <TABLE WIDTH="825" CELLPADDING="0" ALIGN="RIGHT" CELLSPACING="0" BORDER="2" RULES="NONE" FRAME="BOX" STYLE="BORDER-COLOR:#F2952E"> <TR> <TH WIDTH="25"></TH> <TH WIDTH="200">Van</TH> <TH WIDTH="600">Bericht</TH> <TH WIDTH="100">Tijd</TH> <TH WIDTH="100">Datum</TH> </TR> <?php $foutmelding = ""; //Query voor het zoeken naar gemelde storingen $qry = mysql_query("SELECT * FROM `game-berichten` WHERE `aan` = '$login' ORDER BY id DESC LIMIT 0, 10"); if(!$qry) { $foutmelding = "Er zijn geen berichten voor je.".$login; } else { //While loop voor het vullen van de tabel while($row = mysql_fetch_assoc($qry)) { echo '<tr>'; echo '<td>'; ?> <INPUT NAME="checkbox[]" TYPE="checkbox" ID="checkbox[]" VALUE="<? echo $row['id']; ?>"> </td> <?php echo '<td>'; echo $row['van']; echo '</td>'; echo '<td>'; ?> <INPUT TYPE="hidden" NAME="id" VALUE="<?php echo $row['id']; ?>"></INPUT> <INPUT CLASS="bericht" TYPE="SUBMIT" NAME="bericht-open" ID="bericht-open" VALUE="<?php echo $row['onderwerp'];?>"></INPUT> <?php echo '</td>'; echo '<td>'; echo $row['tijd']; echo '</td>'; echo '<td>'; echo $row['datum']; echo '</td>'; echo '</tr>'; } } ?> <TR> <TD COLSPAN=5> <?php echo $foutmelding; ?> </TD></FORM> The exec page: if($_POST['bericht-open']) { $id = $_POST['id']; } echo $id; What happens at this point is that the id of the last message in the table will be displayed always. Who can help me out. Thanks Ryflex
  19. ok nice!! Changed display:block to display:inline-block Problem solved Thanks AyKay47
  20. Hi Guys and Girls, I have a weird thing here. I have got a small script which worked perfectly before I started using CSS. $message =' <CENTER> <FORM ID="Overdracht" NAME="Overdracht" METHOD="POST" ACTION="/standby/index.php"> <SELECT NAME="tijd"> <OPTION VALUE="18:00:00">18:00</OPTION> <OPTION VALUE="07:30:00">07:30</OPTION> </SELECT> <INPUT CLASS="input" TYPE="TEXT" NAME="overdracht" SIZE="15" ID="overdracht">belt voor de overdracht.<BR> <INPUT TYPE="SUBMIT" NAME="Submitoverdracht" ID="Submitoverdracht" VALUE="Log overdracht"></INPUT> </CENTER> <?php '; It always looked like: Selector Input field text Button Since I'm using CSS it looks like this: Selector input field text button What am I doing wrong??? Here's my CSS sheet: body { background-image:url('images/background.jpg'); background-repeat:repeat-x; font-family:verdana; } table, td { font-family:verdana; } ul { list-style-type:none; margin:0 auto; padding:0; width:800px; overflow:hidden; } li { float:left; } a:link,a:visited { display:block; width:180px; font-family:Verdana; font-weight:bold; color:rgb(0,51,111); background-color:rgb(242,147,46); text-align:center; padding:4px; text-decoration:none; text-transform:uppercase; } a:hover,a:active { color:rgb(242,147,46); background-color:rgb(0,51,111); } input { display:block; width:148px; font-family:Verdana; font-weight:bold; color:rgb(0,51,111); background-color:rgb(242,147,46); text-align:center; padding:2px; text-decoration:none; text-transform:uppercase; border:none; } input:hover,input:active { color:rgb(242,147,46); background-color:rgb(0,51,111); } .input, .input:hover { font-family:verdana; font-size:14px; color:black; background-color:white; text-align:left; text-decoration:none; font-weight:normal; text-transform:none;" } And the code where $message is being echoed: <TABLE border=1> <TR> <TD> <DIV ALIGN="left"> <FORM ID="Invoer" NAME="Invoer" METHOD="POST" ACTION="/standby/index.php"> <INPUT TYPE="SUBMIT" NAME="OCE" ID="OCE" VALUE="OCE"></INPUT> <INPUT TYPE="SUBMIT" NAME="OCEoverdracht" ID="OCEoverdracht" VALUE="OCE overdracht"></INPUT> <BR> <INPUT TYPE="SUBMIT" NAME="2e" ID="2e" VALUE="2e Kamer"></INPUT> <INPUT TYPE="SUBMIT" NAME="Oldelft" ID="Oldelft" VALUE="Oldelft"></INPUT> <INPUT TYPE="SUBMIT" NAME="Winvision" ID="Winvision" VALUE="Winvision"></INPUT> <INPUT TYPE="SUBMIT" NAME="Cargonaut" ID="Cargonaut" VALUE="Cargonaut"></INPUT> </FORM> <BR> <BR> </DIV> </TD> <TD WIDTH="800"> <?php echo $message; ?> </TD> </TR> </TABLE>
  21. Thanks it worked. Changed the name of the input button to OCE and in de isset too. Perfect thanks again
  22. Thanks for the quick response. I normally used if($_POST['OCE']) { header("Location: /standby/oce.php"); } for handling but didn't know how to check with the coordinates. How do I know which coordinates to check for because the are diferent each time. Gr Ryflex
  23. Hi all, I'm trying to make a form with several submit buttons. Instead of the boring one's I want to use small images. After searching on google etc. I found the following <INPUT TYPE="IMAGE" SRC="images/oce.gif" ALT="Submit" NAME="submit" ID="OCE" VALUE="OCE" WIDTH="48"; HEIGHT="48";></INPUT> Somehow nothing hapens when I use the button. When I use a GET method it gives me in return some coordinates. I need to use the POST value but is doesn't work. Full form: <FORM ID="Invoer" NAME="Invoer" METHOD="post" ACTION="/index.php"> <INPUT TYPE="IMAGE" SRC="images/oce.gif" ALT="Submit" NAME="submit" ID="OCE" VALUE="OCE" WIDTH="48"; HEIGHT="48";></INPUT> <INPUT TYPE="SUBMIT" NAME="OCEoverdracht" ID="OCEoverdracht" VALUE="OCE overdracht"></INPUT> <BR> <INPUT TYPE="SUBMIT" NAME="2e" ID="2e" VALUE="2e Kamer"></INPUT> <INPUT TYPE="SUBMIT" NAME="Oldelft" ID="Oldelft" VALUE="Oldelft"></INPUT> <INPUT TYPE="SUBMIT" NAME="Winvision" ID="Winvision" VALUE="Winvision"></INPUT> <INPUT TYPE="SUBMIT" NAME="Cargonaut" ID="Cargonaut" VALUE="Cargonaut"></INPUT> </FORM> Can anyone help me. Gr Ryflex
  24. Hi all, I have a dbtable with the columns day, month, year, time, alert In the day column it's the day of the month so 1,2,3 ... 30, 31 In the month column it's 3 letters from the month so Jan, Feb, Mar ... Nov, Dec In the year column you guessed it are the years 2011 in this case. and in the time column it shows times lik 11:11:11 Every time there's an alert on a printer we push a button which inputs the alert and day, month, year and time in the table. Now I need to get out the data between 18:00:00 and 07:30:00 Example between 18:00:00 on 10 Aug 2011 and 07:30:00 on 11 Aug 2011 Can and will anyone know how this is done? Thanks
  25. Can anyone please help me out here
×
×
  • 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.