Jump to content

scootstah

Staff Alumni
  • Posts

    3,858
  • Joined

  • Last visited

  • Days Won

    29

Everything posted by scootstah

  1. Sure. If you go the second route you'll just have to add the right formatting, which can be found here.
  2. You'll need to submit the form when you press enter, not run validation.
  3. Basically, you'll need to use a little logic to end rows and create new ones. One way to do that is to increment a counter and then just test the counter's value. My code is a little different than yours, just for simplicity but it's the same concept. // create an array to loop through $array = range(1,20); // set number of columns per row $cols = 5; // start our counter $i = 0; echo '<table>'; foreach($array as $arr) { // check the modulus of our counter // if it is 0 we have to start a new row if ($i % $cols == 0) { if ($i > 0) { // end the current row if it isnt the first row echo '</tr>'; } echo '<tr>'; } echo '<td>' . $arr . '</td>'; // increment the counter // this is important, dont forget this $i++; } echo '</tr>'; echo '</table>';
  4. You can either convert it to a UNIX timestamp with PHP and then convert it into MySQL's format with MySQL, or just convert it into MySQL format all in one go. $year = $_POST['year']; $month = $_POST['month']; $day = $_POST['day']; $timestamp = strtotime($year.'-'.$month.'-'.$day); $sql = "INSERT INTO table (date) VALUES (FROM_UNIXTIME($timestamp))"; $year = $_POST['year']; $month = $_POST['month']; $day = $_POST['day']; $sql = "INSERT INTO table (date) VALUES (STR_TO_DATE('$year-$month-$day', '%Y-%m-%d'))";
  5. I usually use an unobtrusive fixed-positioned bar at the top of the page that's maybe 50 pixels tall or something for my success messages. I usually run a bit of Javascript to make it disappear after a few seconds, as well as a close button. After say an admin uses the site enough times, adds new content, etc, they're not going to want to see some big annoying success message in the way. They're not going to want to close a bunch of popups every time they make a small adjustment either. The way I do it makes it up out of the way and it disappears by itself. As far as errors, it really depends what kind of error we are talking about. Form validation? Those go back to the form by their respective inputs. If it is some kind of error that should never happen I'll probably log it and throw a HTTP 500 response. An example would be trying to use data that should never be missing, but is - this would probably be a result of someone messing with hidden form data or something, something that just wouldn't happen naturally.
  6. That's the problem, they haven't updated it since then.
  7. Sometimes I pluralize, sometimes I don't. It depends on the context. For example, if we are talking about an associative array for a single user I will make the name singular; probably $user. If it is a multidimensional array containing many users, I will likely pluralize it, so it would be $users. Honestly, it really makes no difference. It's just personal preference.
  8. What have you learned so far? What specifically are you in the process of learning or improving on? I would suggest a blog CMS. You will learn most of what you will use as a PHP developer. There's a lot of room to expand to more advanced topics, like: caching, user authentication, file handling, dynamic URL's, AJAX, etc. You can apply a lot of what PHP offers to a CMS.
  9. Netbeans is okay. Personally I like Eclipse + PDT.
  10. I assume they are logging by IP, since two different browsers don't increase the view. Yep, log by IP or with a cookie.
  11. Yes. Read the manual. http://us3.php.net/manual/en/language.types.array.php
  12. w3schools is an amazing site to learn bad and outdated code. It's terrible, to be honest. It's mildly useful as a quick reference and nothing more.
  13. Yeah, I agree with thorpe. I'd rather have a torrent program that excelled at working with torrents, instead of one that was meh at working with torrents and meh at streaming media. It's not a very big deal to have two programs working in unison for this. As long as the download directory is visible to your network, I don't see a reason that any media streamer couldn't automatically pick up new files.
  14. You shouldn't be overwriting the classes vars when you call buildtable() or getheader(). As an end user, this would be aggravating. Every time I call one of those methods I'd have to reset any attributes I have explicitly set.
  15. If you have all your classes in one file, why do you even need an autoloader? Just include the one file and all the classes will be loaded. You're going against pretty much every OOP standard, though. Split them up.
  16. Maybe something like... $num = 1234; if (!is_float($num)) { $num = (float) ($num . '.00'); } There's probably a better way, but it works.
  17. There's no sure-fire way to tell if a request is unique or not. You can either check by IP or set a cookie or something. Both are not very reliable, but it's the best you can do aside from a login system.
  18. Sorry to be blunt but if you do not know how to create a database, you do not have the ability to do this.
  19. I believe they said it's a security risk to let your users know if the username is wrong. Personally, I usually just go with an ambiguous "user/password combination is invalid" approach. It just makes it that much harder to brute force if you don't even know if the username is valid.
  20. It sounds like you are trying to run a marathon before you can crawl. I think you need to take a step back, start learning the fundamentals of PHP, and then come back when you are ready.
  21. Damn, you guys must be boring IRL.
  22. Instead of explicitly stating which attributes can be placed, just allow everything. It's easier and you won't run the chance of missing something.
  23. That doesn't make sense. You have to specifically look for the break. If you only indent the code in the case but not the break, you know that as soon as the indentation stops there is a break. It is a lot faster to just look at a column of indented text than to find a specific keyword.
  24. My guess is they are selecting something, then looping through it and selecting something else for each result.
×
×
  • 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.