Jump to content

scootstah

Staff Alumni
  • Posts

    3,858
  • Joined

  • Last visited

  • Days Won

    29

Everything posted by scootstah

  1. I'm a long walk from the UK. But that's okay. Enjoy.
  2. Convert it to UNIX timestamps and then compare it. $start = strtotime('22:00'); $end = strtotime('+4 hours', $start); Now, $end is 4 hours after $start - which accounts for days.
  3. Indeed. If this was the first assignment in the class, then I should think he would at least give you some coding guidelines to go by.
  4. Try this: <tr> <tr> <td class="main"><?php echo '<b>' . ENTRY_DATE_PURCHASED . '</b> ' . date('d-m-Y', strtotime($order->info['date_purchased'])); ?></td> </tr> <tr> <td align="center"><table align="center" width="100%" border="0" cellspacing="0" cellpadding="2">
  5. You'll find it easier to use preg_replace, which uses regular expressions. Try this out: $str = 'underline the first e'; $str = preg_replace('/e/', '<u>e</u>', $str, 1);
  6. Well you asked if the change would possibly effect other code. The answer is, we can't tell you. Like I said, something might be depending on a date in that specific format. If you only need it in one location and you don't want to change that function, just reformat it for that page. $date = date('d-m-Y', strtotime(theFunction()));
  7. Well, you can always redirect after processing. Even if you want to end up on the same page, redirecting will make it so refreshes won't resend the form. As for a giant processing file, it just doesn't seem like a clean approach in my opinion.
  8. It most likely will. The first question to ask is, are you positive that an iframe is the right way to go? I can't see why you'd need an iframe for ad rotation. A possible solution is to just force focus onto the game when the iframe is reloaded.
  9. What do you mean by "jump to an item"?
  10. Without knowing what the function does or what uses the function, we can't really tell you for sure. If something is depending on that function giving that specific date format then yeah, you might botch it up.
  11. Can you do echo '<pre>' . print_r($_FILES, true) . '</pre>'; and post back what it outputs? This must be called after submitting the form. Also, are you using enctype="multipart/form-data" in your <form>?
  12. So do it procedurally then... function loadTemplate($file) { if (is_readable($file)) { require $file; } } // contact.php $template = new Template if (!empty($_POST)) { // process stuff if ($success === true) { loadTemplate('success.php'); } else { loadTemplate('errors.php'); } } else { // view form loadTemplate('form.php'); } EDIT: I would also recommend splitting your template files into a header, a body, and a footer. Only use this function to get the body and for each body, just require the header at the top and the footer at the bottom. Otherwise, if you want to change the code in the header or footer you have to do it in every single file.
  13. Damn, I need coffee or something. Here, this should do it: //print users age to 1000 by 3s for($i=$age; $i<1000; $i = $i + 3){ echo $i . '<br />'; }
  14. So don't do that. Use a template library, then you can have simple, elegant code that is separated. Crude example: class Template { public function view($file) { if (is_readable($file)) { require $file; } } } // contact.php $template = new Template if (!empty($_POST)) { // process stuff if ($success === true) { $template->view('success.php'); } else { $template->view('errors.php'); } } else { // view form $template->view('form.php'); }
  15. While it may be obvious in this case what the variables are for, and commenting may not be needed...that won't always be the case. There will be times you have seemingly obscure variables and without commenting, people won't know what the hell is going on. I believe the point here is to teach you that people won't always see things as obviously as you do, being the one that wrote it. It's easy to, in this case, say "oh well it's obvious that PackageWeight is for a package's weight", but later on down the road you might say "well, it's obvious that PW means the package's weight" - even though it make sense if you just stared at it for 6 hours, but someone who just looks at it won't immediately know what it means. I guess you could say "well just use good variable naming" and this is true, but sometimes it just happens.
  16. You should carefully look at melloor's code and then back at your own and figure out where your problem is coming from.
  17. echo $age;
  18. It looks like that because those are seconds. UNIX time is the amount of seconds since January 1, 1970. You can't directly compare MySQL's time/date functions to UNIX timestamps, but you can if you convert them to UNIX first. Try: if(strtotime($get1['date']) > strtotime('-1 minutes')) { By the way, strtotime() calculates its time based off the current timestamp. So if you want to compare it to the timestamp your session holds, you need to give it the timestamp as a second parameter.
  19. Oh, I see now you missed a few other things.... //print users age to 1000 by 3s for($i=$age; $i<1000; $i+3){ echo '$age'; }
  20. Can you show me what you mean?
  21. This sounds like homework, so I'm not posting the answer. However, I can tell you the approach and you can figure it out yourself. To find the first e you can either use some simple regular expressions, or the strpos function. To tell if "son" is the last 3 letters, you could, again, use regular expressions or the substr function.
  22. Okay, so in what way does melloorr's code fail to do that?
  23. scootstah

    show/hide

    I don't quite understand your question. So you want to click an image and have a form pop up?
  24. scootstah

    meta tag help

    The DOCTYPE tells the browser how to parse the HTML. The Content-Type header tells the browser what character encoding the page uses. So yes, because they are completely different things.
  25. Exactly the way you did it, plus a semicolon: //print users age to 1000 by 3s for($i=$age; $<1000; i+3){ echo '$age'; }
×
×
  • 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.