Jump to content

jamesmpollard

Members
  • Posts

    28
  • Joined

  • Last visited

jamesmpollard's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I was wondering if anyone could help! I'm pulling my hair out here. Basically I pull some data down from the DB (start & end) which are both datetime columns. What I need it to do is if the start is say 10:00AM and the end is 12:00PM I need it to add the HTML class "y" to 10,10:30, 11, 11:30 & 12. It did work in one instance, then I tested it again on another example and every TD was class "n". Could someone shed some light on what's going wrong here?[/size] -- I would like to point out here my indentation was all perfect but for some reason it's not when I post it lol.[/size] <?php function betweenTime($input, $from, $till) { $fromTime = strtotime($from); $toTime = strtotime($till); $inputTime = strtotime($input); if(($inputTime >= $fromTime && $inputTime <= $toTime)) { return true; } else { return false; } } foreach ($Appts as $APK => $APV) { $StartI = settype(date('i', strtotime($Appts[$APK]['start'])), 'integer'); $EndI = settype(date('i', strtotime($Appts[$APK]['end'])), 'integer'); $Start = date('H:', strtotime($Appts[$APK]['start'])) . ($StartI >= 30 ? '30' : '00') . date(' a', strtotime($Appts[$APK]['start'])); $End = date('H:', strtotime($Appts[$APK]['end'])) . ($EndI >= 30 ? '30' : '00') . date(' a', strtotime($Appts[$APK]['end'])); $Start_ = date('H:i a', strtotime($Appts[$APK]['start'])); $End_ = date('H:i a', strtotime($Appts[$APK]['end'])); echo ' <tr class="participant"> <td class="pname"><div class="pname">James</div></td> <td class="partTableCell' . ($Start === '08:00 am' || $End === '08:00 am' || betweenTime('08:00 am', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '08:30 am' || $End === '08:30 am' || betweenTime('08:30 am', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '09:00 am' || $End === '09:00 am' || betweenTime('09:00 am', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '09:30 am' || $End === '09:30 am' || betweenTime('09:30 am', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '10:00 am' || $End === '10:00 am' || betweenTime('10:00 am', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '10:30 am' || $End === '10:30 am' || betweenTime('10:30 am', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '11:00 am' || $End === '11:00 am' || betweenTime('11:00 am', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '11:30 am' || $End === '11:30 am' || betweenTime('11:30 am', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '12:00 pm' || $End === '12:00 pm' || betweenTime('12:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '12:30 pm' || $End === '12:30 pm' || betweenTime('12:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '01:00 pm' || $End === '01:00 pm' || betweenTime('01:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '01:30 pm' || $End === '01:30 pm' || betweenTime('01:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '02:00 pm' || $End === '02:00 pm' || betweenTime('02:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '02:30 pm' || $End === '02:30 pm' || betweenTime('02:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '03:00 pm' || $End === '03:00 pm' || betweenTime('03:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '03:30 pm' || $End === '03:30 pm' || betweenTime('03:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '04:00 pm' || $End === '04:00 pm' || betweenTime('04:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '04:30 pm' || $End === '04:30 pm' || betweenTime('04:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '05:00 pm' || $End === '05:00 pm' || betweenTime('05:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '05:30 pm' || $End === '05:30 pm' || betweenTime('05:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '06:00 pm' || $End === '06:00 pm' || betweenTime('06:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '06:30 pm' || $End === '06:30 pm' || betweenTime('06:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '07:00 pm' || $End === '07:00 pm' || betweenTime('07:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '07:30 pm' || $End === '07:30 pm' || betweenTime('07:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '08:00 pm' || $End === '08:00 pm' || betweenTime('08:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '08:30 pm' || $End === '08:30 pm' || betweenTime('08:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '09:00 pm' || $End === '09:00 pm' || betweenTime('09:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '09:30 pm' || $End === '09:30 pm' || betweenTime('09:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '10:00 pm' || $End === '10:00 pm' || betweenTime('10:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '10:30 pm' || $End === '10:30 pm' || betweenTime('10:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '11:00 pm' || $End === '11:00 pm' || betweenTime('11:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '11:30 pm' || $End === '11:30 pm' || betweenTime('11:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '12:00 am' || $End === '12:00 am' || betweenTime('12:00 am', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell n dsep pok"><img src="assets/images/delete.png" width="20" height="20" /></td> </tr>'; } ?>
  2. Sorry about the wrong category. Mod could you move it for me please?
  3. Glad to hear you've solved it and it's brilliant that you've posted how you did too for others to learn from but when you post code, please use the code tags to make it more pleasant on the eye.
  4. I was wondering if someone could shed some light on where I'm going wrong here. I'm trying to make it so that if a user came to my site (in dev mode at the minute so localhost) and used the url for example http://localhost/example/aquery/string. The url it would actually access it http://localhost/example.php?route=aquery/string. Is this possible? Here's what I have so far... Options All -Indexes +FollowSymLinks +MultiViews RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*?)/(.*)$ $1.php?route=$2 [L] DefaultType application/x-httpd-php Any help appreciated. Many thanks James
  5. Thank you for your help! I'm going to hit the reset button and start over!
  6. That's almost what it's going to do when I'm finished, it will have a separate TPL for the header and footer and only really change the body TPL. But for ease of development, I'm trying to get it to parse all the data passed through it correctly which apparently is harder than I thought lol. Basically once the first line (settings{name} & settings{value}) has been parsed, I need it to unset the first result set, then the second and so on. But because everything is dynamic (the results, the requests, etc) I can't set in stone the order, so it's a numbers game. So in essence I need to find a way for the script to go On this line - I need to replace 2 items for the first result set. Then the line after - I need to replace 3 items from the second result set and so on. I was thinking about making it run through every line, gathering a list of replacements needed per line, then sorting them to the results set and str_replace'ing them all using arrays but that didn't seem to work well lol
  7. Excellent, is it all working okay? Or are you still facing the same problem?
  8. Could you run this and post the response please: <?php $host = "localhost"; $dbName = "project"; $dbUname = "root"; $dbPass = ""; try { $conn = new PDO("mysql: host=$host;dbname=$dbName; charset=utf8", $dbUname, $dbPass); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { exit('ERROR: ' . $e->getMessage()); } require_once 'classes.inc.php'; $project = new projecteg($conn);
  9. Using the "settings" key as an example here. What's happening is as it loop's through the system, on the first hit it find's settings{id} and replaces it with the first result set ID. When - if working right, it should be replacing it on the second hit because it's the second "request/line". I've tried making it so that the whole html is broken down line by line and processed that way but that's a massive nightmare and a benchmarking disaster
  10. I've uploaded a screenshot, that array look's ridiculous when pasted lol
  11. That last line confused me a bit lol. This is a print out of my example array: Array ( [members] => Array ( [0] => SQL [1] => 0 [RESULTS] => Array ( [0] => Array ( [id] => 1 [name] => James [email] => test@test.test ) ) ) [settings] => Array ( [0] => SQL [1] => 1 [RESULTS] => Array ( [0] => Array ( [id] => 1 [name] => skin [value] => default ) [1] => Array ( [id] => 2 [name] => sitename [value] => ATestSite ) [2] => Array ( [id] => 3 [name] => atest [value] => test ) ) ) )
  12. Scratch that, just realised.... line 18 is $e->getMessage(); Are you missing a semi colon?
  13. Please post full code for your dbconfig.inc.php or at least line 18
  14. Excellent. Thank you for getting back to me. I was considering it, but it would mean a whole re-write wouldn't it? Is there anything I could do to the existing script that could beef up security or even performance?
  15. Sorry, forgot to add. This is the output once ran: <html> <head> <title>Test</title> </head> <body> <ul> <li>skin - default</li> <li>1 - ATestSite - sitename</li> <li>test - atest</li> <li>James - test@test.test</li> <li>jamess - hi</li> <li>test11 - test22</li> </ul> </body> </html> This is what it should be <html> <head> <title>Test</title> </head> <body> <ul> <li>skin - default</li> <li>2 - ATestSite - sitename</li> <li>test - atest</li> <li>James - test@test.test</li> <li>jamess - hi</li> <li>test11 - test22</li> </ul> </body> </html>
×
×
  • 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.