Jump to content

Lostnode

Members
  • Posts

    77
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Lostnode's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello all. I am using a premade login script which has some very powerful function built in, the one I am looking at using is as follows: /** * query - Performs the given query on the database and * returns the result, which may be false, true or a * resource identifier. */ function query($query){ return mysqli_query( $this->connection, $query); } The issue is, displaying the results. I call is via the following code: $database->query('SELECT LastName, Firstname FROM Patrons WHERE LastName = "Delude"'); But I have no idea how to display it. I have attempted to echo it out, but I get the following error in the logs:
  2. I got hit with an error when trying to use the diff(): [pre] Call to a member function diff() on a non-object [/pre] I am using CodeIgniter as my framework, so something don't quite work as expected. I am happy to say however that CodeIgniter has a very simple function for it.. $in_time = strtotime($this->input->post('in_time')); $out_time = strtotime($this->input->post('out_time')); [color=#002166][font=Monaco, Verdana, sans-serif][size=3][background=rgb(249, 249, 249)]echo timespan($start, $end);[/background][/size][/font][/color]
  3. Ok, I got it working, thank you, now I just have to figure out the display, just gotta get m head wrapped around the logic. Here is what I used: $seconds = $out_time - $in_time; if ($seconds < '900') { $minutes_rounded = ceil($seconds/(60*15))*15; } else { $minutes_rounded = round($seconds/(60*15))*15; } $time_subtotal = ($minutes_rounded / 15) * $time_price; Anything under 15 rounds up, (except for 0, we need that to stay 0) everyting else rounds normally., a lot shorter of a code than what my predecessor used.
  4. Ok, now I see the logic. However, I only want to force a round up if the total time is less than 15 minutes, say the user was in the lab for 7 minutes, I don't want to charge them based on 0 minutes (as the nearest increment is 0), only then do I want it to round up, other wise I want it to round normally, i.e. 25 minutes would round to 30, but 22 minutes would round to 15. Also, once I have my seconds, how do I format it to be in H:i format as date() doesn't do it (900 seconds, places in date('H:i', 900) = 19:15 instead of just 0:15......)
  5. I was mearly asking an explanation as to why you used "while", as usully loops not used in a single calculation. Or atleast I have not seen it used often unless I am running through lots of data. I will try it out when I get back to my PC later this afternoon.
  6. Why the while? The calculation is upon the patrol looking to leave, so the time no long increments, when they check in a time stamp is placed, as well as at the time they which t check out. FOr istance: Check in: 2013-02-21 10:15:21 Check Out: 2013-02-21 11:20:12 By eyeballing it I know its 65 minutes or 1:05 in h:i format I need to figure out how to round it to the 1:00, and then charge the $2.00 based on $0.50 per 1/4 hour. If I strtotime('out_time') - strtotime('in_time') I get the total seconds, getting it to the minutes part is not hard, but I want it to displat as H:i (1:00) and not 60minites.
  7. Out of the several frameworks that are out there I have taken a liking to CodeIgniter, a very extensive framework with a fairly small foot print. It meets your criteria as well.
  8. I am working on piece of software for the computer center I work at, in actuality improving on a 7 year old application that is well overdue for an update in functionality and features. The part I am getting stuck on is that we charge the public by the 15 minute increment, and everything is done via the ISO time stamp (YYYY-MM-DD HH:MM:SS) or date('Y-m-d H:i:s'). I have no issue getting the difference via strtotime() which gives me the difference in seconds. The problem is getting it to round to the same format so that it can be displayed in format ('H:i'), and I need to somehow calculate the total cost of the time, for instance we charge library members $0.50 per 15 minute interval. My predecessor used the following, which I think is a bit overkill (was finding it hard to understand how he coded the app) if ($minutes == 0){ $minutes = 0; $chunk_minutes = 0; }elseif($minutes > 0 AND $minutes <= 7){ if ($hours > 0){ $minutes = 0; $chunk_minutes = 0; }else{ $minutes = 15; $chunk_minutes = 1; } }elseif($minutes >= 8 AND $minutes <=22){ $minutes = 15; $chunk_minutes = 1; }elseif($minutes >= 23 AND $minutes <= 37){ $minutes = 30; $chunk_minutes = 2; }elseif($minutes >= 38 AND $minutes <= 52){ $minutes = 45; $chunk_minutes = 3; }elseif($minutes >= 53){ $minutes = 60; $chunk_minutes = 4; }else{ $minutes = "error rounding"; } I am looking for something a little less complex. Then the next issue is if its less than 15 minutes, rather 7 minutes or less, I need it to round up to 15 where usually it would round down to 0. If anyone can shed some light on this it would be appreciated. Regards
  9. Thank you both for the ideas. I never thought of doing it that way, and it is much simpler than the track I was on. I will figure out a way to do it as there will be stand alone apps which simply check is a key is valid before the software lets them in, I will just have the software mark the last time the key was checked and store it in memory.
  10. I am creating a multi-user system and want to broadcast system updates to a dashboard (when they log in they see the new messages). The user can then close the message, making it disappear from the screen without refreshing. I know that this would have to use ajax and jquery, but for the life of me I cannot find anything on the net to help me. I can find stuff on pop up notifications but its not quite what i am looking for. I am looking at it pulling a list of notifications/updates from a mysql database and after the user reads it, its gone (but they can click an archives button and read them all in case they accidentally clicked one off) but I am looking for a more efficient way of doing it then having an entry for every user put into the database after they have read it do it doesn't pop up again next time they refresh the page. Is this possible or so I absolutely have to make an entry for each? Also if anyone has any tutorials on the ajax/jquery functions I need to make this work it would be much appreciated. Also, just to add the the mix, I am creating it to be a desktop application with EXEOutput, would it be easier/possible to make it so that if I do need to do an entry per each user, it put the entry into the SQLite flat file db on the local system and not the mysql server? So that it pulls the data from the MySQL DB on the main server and cross references those already viewed by pulling from the local SQLite DB? Just looking for some hints on how to accomplish this. LostNode.
  11. No they are not in the database, that hadn't even occurred to me to do it that way. I will think it over and see if I can come up with a solution, I will post my code if I get into trouble with it.
  12. It will be stored as an integer, 1 through as many modules will be created (currently 5 but potentially more) and the variables are descriptive of the module, currently $cpord, $tnord, $dhord, $amord, $feord. the files them selves are name based, canpar.php, tnt.php, dhl.php, aramex.php and fedex.php, This is to grow of course, more includes and more order variables.
  13. Thanks for the quick reply, I will have to think about this a bit more, as my includes aren;t actually called include#.php, they are actually named... worse come to worse, I may have to number them. As for $order, I am not sure how that would work either, as I need to pull the variables from the database... I will test it out tomorrow when I get to the office... Could this work? $order = "$var1, $var2, $var3, $var4";
  14. I am having difficulty wrapping my head around how I can sort things easily. Basically I have a few chunks of code which I will be extracting and making into includes to tidy up my code, but what I am looking for is a way to sort the includes by user preference. For instance say I have 4 include files, incude1.php though include4.php, user 1 wants them to show up 1, 2, 3, 4, user 2 wants them to show up 1, 3, 2, 4 and user 3 wants them to show up 4, 1, 3, 2.... I was thinking about using if statements but that is most definitely not the right way to go. The structure for this would be in the settings table, so they would set their preferences there, but I am stuck on how to get it to physically put things in the right order. I am sorry I have no code to show as I have absolutely no idea of where to start. I am looking for a push in the right direction (then I can post some code when it goes horribly wrong) Any help would be appreciated.
  15. As far as I know, I have been checking the error_log and see nothing in there that about this particular issue. I have come up with a fix, which I am not happy about but it will have to do as it DOES work. I moded the logout.php file so that the removal of the cookies falls under the !logged_in() part and it seems to work fine, but i really would like them to be logged out before clicking the link to log back in.
×
×
  • 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.