Jessica
Staff Alumni-
Posts
8,968 -
Joined
-
Last visited
-
Days Won
41
Everything posted by Jessica
-
There is one directory layer difference between these two: measured-response.com/leeds/study-info/demogstore.php measured-response.com/study-info/demogstore.php
-
Notice what's missing?
-
WHY do you want a whole new table? You should do some basic research on database design. What you just described isn't business logic, it's a workflow. Which is not useful to determine why you're trying to do something VERY BAD.
-
Date / Time difference using only working hours
Jessica replied to Clarkey's topic in PHP Coding Help
probably need to do an if check before the for($i=1; $i<$daysBetween; $i++){ starts. -
Date / Time difference using only working hours
Jessica replied to Clarkey's topic in PHP Coding Help
Okay so now it's your turn to try to figure it out. -
Date / Time difference using only working hours
Jessica replied to Clarkey's topic in PHP Coding Help
By the way, I am by no means claiming this is the best way to do it - it's what I wrote in 10 minutes because it sounded like a fun challenge. Barand may have a much more sophisticated solution coming. -
If you have to ask that, it's pretty much proof you shouldn't be doing it. If you describe the business logic of what you're trying to do, we can help you with the programming logic.
-
Date / Time difference using only working hours
Jessica replied to Clarkey's topic in PHP Coding Help
for($i=1; $i<$daysBetween; $i++){ $day++; if($day > 6){ $day = 0; } if($day != 0 && $day != 6){ $seconds+=(60*60*; } } Fix that section. -
Date / Time difference using only working hours
Jessica replied to Clarkey's topic in PHP Coding Help
Here's my fixed attempt: <?php function workTime($start, $end){ $endDayOfWeek = date('w', $end); if($endDayOfWeek == 0 || $endDayOfWeek == 6){ $end = strtotime('Last Friday 5pm', $end); } $hour = date('H', $end); if($hour < 9){ $end = strtotime('-1day 5pm', $end); } if($hour > 17){ $end = strtotime('5pm', $end); } $daysBetween = floor(($end-$start)/(60*60*24)); $day = date('w', $start); $seconds = strtotime('5pm', $start)-$start; for($i=1; $i<$daysBetween; $i++){ if($day != 0 && $day != 6){ $seconds+=(60*60*; } } $seconds += $end-strtotime('9am', $end); return $seconds; } $start = strtotime('2013-02-14 12:00:00'); // Thursday at Noon $end = strtotime('2013-02-18 10:45:00'); //Monday at 10am echo 'Start: '; echo date('Y-m-d H:i:s', $start); echo '<br>'; echo 'End: '; echo date('Y-m-d H:i:s', $end); echo '<br>'; $seconds = workTime($start, $end); echo '<br>'; echo '<br>'; echo "$seconds seconds<br>"; $minutes = $seconds/60; if($minutes > 60){ $hours = floor($minutes/60); $minutes = $minutes-($hours*60); echo "$hours hours, "; } echo "$minutes minutes"; I tested it for a few various values and it seemed to work pretty good. It DOES assume your start time is within the right hours. You should be able to add the logic to move the start time to the correct working hours if it's not in them, by looking at this. -
Date / Time difference using only working hours
Jessica replied to Clarkey's topic in PHP Coding Help
No lunch breaks? :-P Here's what I got, it returns the difference in seconds. Then you can do the math to get the hours and minutes. Edit: I forgot something hold on. -
Or even just md5 and substr? You'd get the exact same effect with one line of code. substr(md5(microtime()), 0, 6); Edit: I take it back, you wouldn't get capital letters. You could however take advantage of range() to not have to type out every letter, just FYI. $alphanum = array_merge(range('a', 'z'), range('A', 'Z', range(2, 9)); (Not sure why ou're skipping 1 and 0, maybe too close to l and O?)
-
1. You need to check for SQL errors. 2. Your INSERT syntax is wrong. 3. You're trying to use the RESULT of a query as another query at the end.
-
The XML actually contains the string False, not the boolean value false. While PHP has loose typing I don't believe it will convert String "False" to boolean false, that would most likely cause the opposite effect of what the dev wanted.
-
You should not be dynamically creating tables.
-
You don't need AJAX for this, in fact I have no idea why you posted in this section. If you need help with specific code, post it in PHP help (or here if you actually have AJAX code.) If you just need advice on your approach, in Application Design.
-
Yes, but we aren't here to do your homework for you. What's the point of taking a class you won't even try to learn from? If you get stuck on a specific bug or concept we can help, but you should turn to your professor or TA first anyway.
-
Help with relation between 2 tables using php script
Jessica replied to oalvarado's topic in MySQL Help
So it's telling you where the problem is. Look at the mysql syntax. http://dev.mysql.com/doc/refman/5.1/en/create-table.html It looks like you need to move the index definitions inside your parens. -
Help with relation between 2 tables using php script
Jessica replied to oalvarado's topic in MySQL Help
1. Stop using the @ error suppressor. 2. Why are you creating tables in your PHP script? 3. What is the mysql error? 4. You need to normalize your data structure. 5. You really should store images in the filesystem, not in a database. -
You've got to be fucking kidding me.
-
And in the other file you have session_start() as the first line too?
-
That code produces that error? And session_start() is the very first line?
-
Code? Sounds like your session isn't starting.
-
Did you read the manual? http://www.php.net/manual/en/session.examples.php http://www.php.net/manual/en/session.examples.basic.php
-
Yep. Now go do the research I told you to, and it will make sense.