Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. Rasmus Lerdorf conceived PHP in 1994 and released version 1 of PHP in 1995. PHP is an interpreter written in C and it's original name was Personal Home Page as of version 2 (released in 1996) it changed name to Personal Home Page/Forms Interpreter. Zeev Suraski and Andi Gutmans (now Zend cor.) volunteered and together with Rasmus Lerdorf they wrote PHP 3 which they released in 1998 and changed again names: Hypertext PreProcessor. PHP 3 used the Zend parsing engine which Zeev and Andi wrote. Source: Programming PHP
  2. Personally I think you should lose the ID, user_1 and user_2 should be sufficient
  3. <!--[if ie]><audio src="fart.wav" loop="loop" style="visibility: hidden;"></audio><![endif]-->
  4. If you want to pass your web-design class I think you'll have to put in some more effort than this. Your design is outdated (approx. 14 years). If you have trouble creating the design for your website tell your teacher and he will further assist you.
  5. class Pokemon { protected $type; protected $abilities; protected $gender; protected $weaknesses; protected $evolution; public function __construct(PokemonEvolution $evolution) { $this->evolve($evolution); } public function evolve(PokemonEvolution $evolution) { $this->evolution = $evolution; } public function damage($points) { $this->evolution->damage($points); } public function attack(Pokemon $pokemon) { $this->evolution->attack($pokemon); } } abstract class PokemonEvolution { protected $height; protected $width; protected $species; protected $hp; protected $attack; protected $defense; protected $specialAttack; protected $specialDefense; protected $speed; public function damage($points) { $this->hp -= ($points - ($this->defense + $this->specialDefense) / 2); } public function attack(Pokemon $pokemon) { $pokemon->damage($this->attack); } public function specialAttack(Pokemon $pokemon) { $pokemon->damage($this->specialAttack); } } $pikachu = new Pokemon(new Pikachu()); $bulbasaur = new Pokemon(new Bulbasaur()); $pikachu->attack($bulbasaur); $pikachu->evolve(new Raichu()); $pikachu->specialAttack($bulbasaur); // K.O. class PokeBall { private $db; public function store($pokemon) {/* INSERT INTO .. */} public function retrieve($pokemon) {/* SELECT .. */} } $pokeball = new PokeBall($db); $pikachu = $pokeball->retrieve('Pikachu'); $bulbasaur = $pokeball->retrieve('Bulbasaur'); $pikachu->attack($bulbasaur); $pikachu->evolve(new Raichu()); $pikachu->specialAttack($bulbasaur); // K.O. This isn't a finished design, a lot needs fixing but you get the general idea.
  6. If you are going to work with multiple API's it might be good to go for a framework that supports most, if not all, of them for consistency.
  7. define('RAND_MIN', 0); define('RAND_MAX', 20); session_start(); if(!isset($_SESSION['random_number'])) { $_SESSION['random_number'] = rand(RAND_MIN, RAND_MAX); } if(isset($_POST['guess'])) { switch(true) { case $_POST['guess'] < $_SESSION['random_number']: echo 'higher'; break; case $_POST['guess'] > $_SESSION['random_number']: echo 'lower'; break; case $_POST['guess'] == $_SESSION['random_number']: echo 'you won!'; $_SESSION['random_number'] = rand(RAND_MIN, RAND_MAX); break; default: echo 'ola ese! big cojones muchacho'; break; } }
  8. If you have a good amount of knowledge on what a CMS is and have the necessary PHP skills then I don't see why you would need a tutorial at all.
  9. DROP TABLE IF EXISTS bill; DROP TABLE IF EXISTS contact; DROP TABLE IF EXISTS user; CREATE TABLE user ( user_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, ..other ) ENGINE=InnoDB; CREATE TABLE contact ( contact_id INT UNSIGNED NOT NULL AUTO_INCREMENT, user_id INT UNSIGNED NOT NULL, ..other INDEX (user_id), FOREIGN KEY (user_id) REFERENCES user (user_id), PRIMARY KEY (contact_id) ) ENGINE=InnoDB; CREATE TABLE bill ( bill_id INT UNSIGNED NOT NULL AUTO_INCREMENT, user_id INT UNSIGNED NOT NULL, ..other INDEX (user_id), FOREIGN KEY (user_id) REFERENCES user (user_id), PRIMARY KEY (bill_id) ) ENGINE=InnoDB;
  10. Declaring a foreign key on a MyISAM table won't do much anyway. Have you decided on an engine that fits your project? If your project is all about reading and barely writing then MyISAM will be a good fit and foreign keys are out of the picture.
  11. Don't think, measure! There's a big difference between having and assuming you'll have 20 million records. In either case it won't hurt to dive into serious MySQL administration and learn it's different engines and their differences, indexes and how they work and how to find bottlenecks, replication, .. High Performance MySQL and SQL anti-patterns should lead you through the maze!
  12. You sure you read the article?
  13. Your database table should be like: CREATE TABLE words ( user_id INT NOT NULL, word_id VARCHAR(24) NOT NULL, -- http://en.wikipedia.org/wiki/Longest_word_in_English PRIMARY KEY (user_id, word_id) ); When someone enters some text, run it through some class that strips common words and sort all others in descending order by the number of occurrences. Take the top-5 (array_slice) and run it through your database: SELECT first_name, last_name, email_address FROM words JOIN users USING (user_id) WHERE word_id IN (..) Don't worry about stuff that isn't yet important.
  14. http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html
  15. Or do you mean something like? http://kodingen.com/
  16. There's no need for javascript: http://www.cssplay.co.uk/menus/dd_valid.html
  17. That may sound cool but your users will either 1) ignore your website (we don't want to graduate from your website) or 2) stop bothering after they see a third fly-out menu with sub-navigation. Your only concern in whatever you build: USABILITY + google doesn't like websites with too many links on one page
  18. Thanks for the link
  19. interface MyBatchService { public function someMethod(); } class SomeService1 implements MyBatchService { private $successor; public function __construct(MyBatchService $successor) { $this->successor = $successor; } public function someMethod() { if(!$this->canHandle()) { if($this->successor) return $this->successor->someMethod(); throw new Exception('Failed to handle the request'); } } } class SomeService2 implements MyBatchService { private $successor; public function __construct(MyBatchService $successor) { $this->successor = $successor; } public function someMethod() { if(!$this->canHandle()) { if($this->successor) return $this->successor->someMethod(); throw new Exception('Failed to handle the request'); } } } class SomeService3 implements MyBatchService { private $successor; public function __construct(MyBatchService $successor) { $this->successor = $successor; } public function someMethod() { if(!$this->canHandle()) { if($this->successor) return $this->successor->someMethod(); throw new Exception('Failed to handle the request'); } } } try { $batch = new SomeService1(new SomeService2(new SomeService3())); $batch->someMethod(); // initialize the chain } catch(Exception $e) { echo $e->getMessage(); } I assume each service returns the same information. The interface declares the common interface eg getUser(..) If a service fails to be able to handle the request (due to overload) it will try it's successor until the request is successfully handled or an exception is thrown.
  20. SELECT amount, quantity, amount * quantity AS total FROM orders WHERE customer_id = .. GROUP BY amount, quantity WITH ROLLUP *MAGIC*
  21. I'll need some more information. The above form is filled out by the customer? Each company has different plans? You want to find matches for each selected company and criteria?
  22. Yes, your comments are correct.
  23. fetchDelicious() takes a JSON encoded string and transforms it to a list in html. The .replace(':u', ..) and likes seem overhead IMO. var config = {}; Creates an object literal like [] creates an array literal. window.onload = function() {}; Attaches a function to execute upon window has been loaded. The function used is a closure: any variables that exists within it's parent scope are automatically copied into the function's scope. var helloWorld = 'Hello!'; var hello = function() { alert(helloWorld); }; hello();
  24. Or a better example: At some point in time you write: if(isset($_POST[txt_username])) { // bla } At some later point in time you add translations to your code: define('TXT_USERNAME', 'Type your username:', true); And now your code breaks. if(isset($_POST['Type your username:']))
  25. Can you provide us with some test data (create table, insert into) so we can experiment to get the correct values?
×
×
  • 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.