Jump to content

KevinM1

Moderators
  • Posts

    5,222
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by KevinM1

  1. This topic has been moved to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=345549.0
  2. Case statements 'fall through', meaning that if you have a condition that matches a particular case, then that case and all cases below it will execute, unless you specify them not to. This is the same for all languages with switch/case, not just VB. That includes PHP. So, how do you tell a case to execute without falling through to the next case? You add a break statement to the end of that particular case's code.
  3. An email form is simply a normal HTML form. On the back end, you simply take the $_POST data, validate/filter it like normal, and then put it into the mail function. An HTML email form, by itself, won't do much to eliminate spam. If that's your worry, you'd need to implement some sort of CAPTCHA as well (Google search result for "PHP CAPTCHA" ).
  4. Since the OP feels the topic has run its course, and because no one can act like an adult, this thread is closed.
  5. Why not break your commands into external modules and have your switch load and access the correct one? Also, are you minifying your JS?
  6. No. A foreach does not contain a conditional component. If you need a conditional, use a for-loop or while-loop.
  7. Letter-spacing isn't adversely affected by a doctype. What a doctype does is ensure your site renders in standards mode. Without a doctype, your site is rendered in quirks mode, which is bad as it essentially uses the old IE (<= 6) box model, which is, to be blunt, screwed up. If anything made things look bad, it was that you designed without a doctype first, then tried to add one in after the fact. What looked good in quirks mode naturally looked bad in standards mode.
  8. You could always pass in an array of parameters, too....
  9. This topic has been moved to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=345338.0
  10. Would it then be a closure?
  11. Can functions even be defined in other functions?
  12. Functions have an argument/parameter list, which is denoted by parentheses. When you define your function, you can tell it to accept parameters to use inside the function in order to do work on them: function example($arg1, $arg2) { // do something with $arg1 and $arg2 } In the code above, the function example will take two parameters and act on them. When you want to actually invoke your function, you'll need to place the variables you want to pass into the function within its parentheses: $x = 3; $y = "Yo momma"; example($x, $y); If you need your function to create a value to use in the rest of your code, you need to return it, like so: function example($arg1, $arg2) { // do something with $arg1 and $arg2 return $someResult; } // ... code ... $x = 3; $y = "Yo momma"; $result = example($x, $y); For more detail, look at functions
  13. Looks good. My only crit is that your footer is unnecessarily tall, and gives me a vertical scrollbar. 'Thick' footers are all the rage, but if you don't have the content to fill one, then don't use one. You could remove ~50% of its height, keep the effect, and remove the scrollbar from the pages entirely.
  14. <?php $link ='index.php?sent'; if (!isset($_GET['sent']) && !isset($_GET['sent1'])) include 'contact.php'; ?>
  15. Part of the problem is that you're panicking and throwing shit at the wall to see if it will work, without actually understanding what your code is doing. This is evidenced by you misunderstanding what Buddski was trying to tell you. So, take a deep breath and calm down. Programming is frustrating, but getting worked up over it will only make it harder for you to learn. Also, comments like: Will only lead to people not wanting to help you. Everyone here - including those of us with badges under our names - are volunteers. We don't see one red cent for being here. No one is obligated to help you. Remember that when you get frustrated. So, all that said, here is what Buddski was trying to tell you: if (isset($_GET['action']) && isset($_GET['size']) && $_GET ['action'] == 'add') { $_SESSION['cart']['content'][] = array ( 'size' => $size, 'id' => $id); // <-- add item to your cart's content array } if (empty($_SESSION['cart']['content'])) // <-- if the cart doesn't contain any content { echo "No products in cart"; } else { foreach ($_SESSION['cart']['content'] as $content) { echo "{$content['id']}, {$content['size']}"; } } Finally, you would be well served to brush up on the basics. Basic if/else syntax, arrays, echo syntax... a lot of the most basic stuff is tripping you up, making it a lot harder for you to get results. You're trying to run without being able to even crawl.
  16. You're overthinking it: $myObject->$the_function_to_call();
  17. The PHP manual is your friend: empty. Note how the correct syntax is different than what you have. Keep a bookmark to the manual.
  18. http://pxtoem.com/ Pixel to Em conversion. Great for accessibility and elastic layouts.
  19. Without seeing your code, I'mma gonna guess it's due to solar flares.
  20. One more thing - since you're extending MySQLi, you don't need a $mysqli data member. Why? Because your class is MySQLi, with extra bits added on top. Anything that's public or protected in MySQLi is automatically available to you. So, in your constructor, if you need to access the parent's (MySQLi's) constructor, you can simply do this: parent::__construct(/* args */); Before you go much further, you should really read up on the basics of OOP. A good place to start is: http://php.net/manual/en/language.oop5.php
  21. It's an infinite loop because each turn in your while-loop rebuilds the initial query result before fetching the data. You won't be able to do what you want in one line of code. You'll need to build and run your query outside of the loop, then fetch the data from the result inside the loop.
  22. Do you actually return anything from your function?
  23. Ah, didn't know that. I like the first two options better than the third, as they reinforce consistency by keeping single quotes around the key.
  24. When echoing array values in a double quoted string, you have two options: 1. String concatenation echo "Some string " . $array['key']; 2. Using inline curly braces to force interpolation echo "Some string {$array['key']}";
  25. First, I'm a bit weary about how you're using static classes. They allow one to break scope, so they should be used sparingly. Static classes are really best used as utility classes, not main components. Also, like I said before, objects can contain other objects. Quick (canned) example: class Example { private $db; public function __construct($database) { $this->db = $database; } public function query($data) { $this->db->query($data); } } Your Pages should contain a reference to your database. How that reference is obtained depends on whether or not you're accessing an actual instance of your class/object, or if you're merely accessing it in a static fashion.
×
×
  • 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.