Jump to content

matthewhaworth

Members
  • Posts

    234
  • Joined

  • Last visited

    Never

Everything posted by matthewhaworth

  1. Erm, I imagine the strtotime(); function could help.. <?php $date = "08/23/1990"; $days = strtotime($date) / (60 * 60 * 24); ?> Or you could make a function of it if you wish <?php function to_days($date) { $r = strtotime($date) / (60*60*24); return $r; } So the first code would then be <?php $days = to_days("08/23/1990"); ?> I tried it with your sample data - didn't work lol, sorry lol.
  2. I had already noticed that, thank you however Ken. The solution that I posted is definitely functional given that $row['Date'] produces the create format for strtotime()
  3. <?php // Today's date $tday = date('d/F/Y'); // Yesterday's date $yday = date('d/F/Y', strtotime('-1 day')); // Date in question $rowdate = date('d/F/Y', strtotime($row['Date'])); // Display date if ($rowdate == $tday) { $ddate = "Today"; } elseif($rowdate == $yday) { $ddate = "Yesterday"; } else { $ddate = $rowdate; } //Display the row of data $output .= "<tr bgcolor=\"$bgcolor\">\n"; $output .= "<td>".$row['Receiver']."</td>\n"; $output .= "<td>".$row['Amount']."</td>\n"; $output .= "<td>".$ddate."</td>\n"; $output .= "</tr>\n"; // I'm not a fan of concatenating functions ... // MH ?> Lol made an elementary mistake that i HAD to correct lol, jeez that was bad. Forgive the double post. Also bare in mind it requires the American date format for input M/D/Y from $rows['date'] TESTED: Works.
  4. <?php // Today's date $tday = date('d/F/Y'); // Yesterday's date $yday = date('d/F/Y', strtotime('-1 day')); // Date in question $rowdate = date('d/F/Y', strtotime($row['Date'])); // Display date if ($rowdate = $tday) { $ddate = "Today"; } elseif($rowdate = $yday) { $ddate = "Yesterday"; } else { $ddate = $rowdate; } //Display the row of data $output .= "<tr bgcolor=\"$bgcolor\">\n"; $output .= "<td>".$row['Receiver']."</td>\n"; $output .= "<td>".$row['Amount']."</td>\n"; $output .= "<td>".$ddate."</td>\n"; $output .= "</tr>\n"; // I'm not a fan of concatenating functions ... // MH ?> Any problems, email me matthew_haworth (at) hotmail.com I leave @ out to avoid junk mail ; ). Bare in mind that the date in $row['Date'] may not comply with the strtotime function..
  5. The function 'array_rand' may prove more efficient. http://uk.php.net/manual/en/function.array-rand.php <?php $randomKey = array_rand(arrayName); $randomValue = arrayName($randomKey)); ?>
  6. As people have touched on earlier, I believe the postfix .class.php is applied to avoid confusion when using the __autoload magic function. Just a guess. But say I used display php pages parallel to classes then the confusion would arise when I have members.php and members.php; the former being a page that displays the members using the members class to works with a DAO to return all necessary information. Think of phpBB they do something.. similar.. however they separate their classes, well, includes, with a folder. So meh.
  7. The problem you're having is that the static variable is private to that function and therefore cannot be called externally. If you made it look like this.. <?php class Dog { public var $myString; // constructor function DogConstructor() { // BEGIN constructor $this->myString = 'Seriously totally awesome'; } // END constructor } // END class Dog echo Dog::DogConstructor; echo Dog::$myString; ?> This might not work in PHP4 though..
  8. http://uk3.php.net/manual/en/function.imagecopyresized.php That function may help you . Edit: haha someone's just had another problem in another thread about something similar.
  9. There is a good tutorial on how to make a calender application in the book: PHP, MySQL and Apache that is likely to be available at (no doubt) a high price from Amazon. So let's take the more modern, open-sourced, 'cost-free' outlook on this. I realise what you intend on making is pretty simple. It requires knowledge of basic PHP and also requires simple knowledge of date and time functions (of which I am sure there's many tutorials on the internet dedicated to). On another note, largely to moderators (to fix it ). I am getting far sick of these types of posts now. I am seeing them everywhere. If you're after a tutorial, or anything similar there is a forum dedicated to it.
  10. Speak in layman's terms for this? We're talking about getting data and applying it to a map via extended programming libraries . Basically, you're jumping the gun a bit. You're better off learning the basics of HTML before you even being PHP, once you have began PHP you need to venture into the more, GD side of things. http://www.libgd.org/Main_Page. They'll help create your graphs. Outside of HTML and PHP you need to enthuse the practical elements. Firstly, where are you getting the raw data from? Is it definitely within your interest to be processing this data into information? Do you have the ability, time and effort to put yourself into such a demanding task. I notice you already have a website up so some of these questions may seem somewhat patronising, but they are, whether you like it or not questions you should ask yourself before developing a web application, noob or pro. Good luck with your work .
  11. That's like saying "It's not a web server doing it, it's a client side language doing it!" It's kind of meaningless, and is so broad as to encompass THE ENTIRE INTERNET. No. No it's not. I get where you're coming from, but it's not. Also, I wouldn't use the method that is suggested as that would make the form load as that would mean it'll refresh every 20 seconds, every time it loads, unless you use flow control statements. I'd invest in Javascript for this, if not Flash?
  12. *sigh*. phpfreaks.com exists for a reason, it contains more than a forum, it contains tutorials. Google.com is also slightly useful.
  13. <div id="content" style="width:<?php if ((mosCountModules( "left" )) < 0) { if ((mosCountModules( "right" )) < 0) echo "800"; } elseif ((mosCountModules( "left" )) > 0) { if ((mosCountModules( "right" )) > 0) echo "380"; } elseif ((mosCountModules( "left" )) < 0) { if ((mosCountModules( "right" )) > 0) echo "590"; } elseif ((mosCountModules( "left" )) > 0) { if ((mosCountModules( "right" )) < 0) echo "590";; } ?>px"> </div> Your syntax was completely wrong?
  14. abstract class userFactory { public static function getUser($levelname, $db) { return new $levelname($db); } } So, will that definitely work?
  15. One would like to question why you would want to do such a thing. However, it would only work if the remote server was expecting a remote script. Otherwise, and correct me if I'm wrong, I believe it's impossible to get data from it.
  16. What if you had thousands of users? It's a big request on the server every time someone deletes an account. Also, a solution has already been provided my DBMS's, so 'why reinvent the wheel'. I hear that said all over these forums.
  17. No, don't take the easy way out, it'll prove terribly inefficient. What if you delete a record so you only have 6 records but the latest id is 7? It'll try to add 7 again and result in an error. http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html phpMyAdmin should deal with it for you. It works best for primary keys, and I'm assuming iD will be your primary key .
  18. If you're using MySQL, though I'm sure it's possible in other DBMS... you can add something named 'auto_increment' onto the field and the database deals with that for you.
  19. It's always best to print out your query as a form of debugging add. <?php echo $query1; ?> Before the query is executed and the problem may become obvious to you .
  20. Put 0. Because you can't rent something for 0 amount of time. That's most people's solution .
  21. Why would you want to do that? Also, infinity is not a number, it is a term, therefore it does not exist and cannot be written in MySQL.
  22. <?php class MySQL { function DoQuery($query, $link) { // Do Stuff } } class FunStuff { private $_db; function __construct($db) { $this->_db = $db; } function DoMore(MySQL & $MySQL) { $blah = $this->_db->DoQuery('blah', 'blah2'); $query = $this->_db->FetchArray($blah); return $query; } } $db = new mysql(); $fun = new FunStuff($db); ?> Hope this helps
  23. C? what C have you been reading? lol. This is the wrong forum chuck. There's a child/sub forum in apache dedicated to what you're asking.
  24. http://www.colormatch.dk/.. that may help you.
×
×
  • 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.