Jump to content

obsidian

Staff Alumni
  • Posts

    3,202
  • Joined

  • Last visited

Everything posted by obsidian

  1. Looks like you have the gist of it, but you have a couple references out of place in your code. For instance, your value is always set to $year, so no matter what is selected, you will always have this year's value submitted. Here is how I would do it, but it really is only slightly different from what you have: <?php echo "<select name=\"year\">\n"; $y = date('Y'); for ($i = $y; $i < ($y + 7); $i++) { echo "<option value=\"$i\""; echo $y == $i ? ' selected="selected"' : ''; echo ">$i</option>\n"; } echo "</select>\n"; ?> Since you are initially priming $i to the current year, you shouldn't have to check at all, really. A select field always defaults to its first value, so unless you are wanting to compare against other options, you may not have to do the comparison at all.
  2. Well, it starts with having a database to house your information. For a link page as simple as that you have shown us, it really would take a matter of an hour or less to get everything together for it, if you know what you're doing. The biggest time consumption will come from gathering the resources themselves. Once you have the DB populated, you just need a simple loop to retrieve all the records and list them out to the screen in the format you specify. Pagination can be a bit tricky for someone getting started, but there are enough tutorials and threads on this site to help you through with that that it shouldn't take you any time to get up to speed. Good luck!
  3. Well, first off, if you are storing your dates in the DB as a DATE or DATETIME type, you can do it with SQL: SELECT (datecol + INTERVAL 3 DAY) AS expiration FROM table_name; Now, to answer your question directly, try something like this: <?php $date = '9/4/2008'; echo date('m/j/Y', strtotime($date . " + 3 day")); ?>
  4. You need to use foreach: <?php foreach ($arr as $i => $row) { foreach ($row as $k => $v) { echo "Current path: {$i} -> {$k} -> {$v}<br />\n"; } } ?>
  5. Thanks for the insight, effigy. As always, you have a very well thought through method, and it seems to work well, too. As I suspected, there is really no easy way to approach this, so I'll check out the links you provided. I'm not excited about getting the Pear library involved in this (I had looked into that before), since this is for an open source project, and I would rather not be reliant on yet another library. Thanks again. I'll mark this as solved for now.
  6. OK, while possibly not the best solution, here is what I have settled on for the time being (until I come up with something better): Step #1: Replace all strings with temp vars using the following pattern: '([^'\\]*(\\.[^'\\]*)*)' Step #2: Replace all occurrences of the table names within the remaining query text Step #3: Replace the strings back into the query This works well, but I just feel that it may be overkill. Any additional thoughts would be greatly appreciated!
  7. Very nice. Turned out I was following my direct link to http://gears.google.com/chrome instead of the slashdot link to http://www.google.com/chrome. I was getting the unstyled (no header) content instead of the full page. I'm very impressed with the relative speed and rendering of everything thus far. I'll definitely have to give it a go for a bit. I will have to be sure that many of my much used dev tools will be portable in some way or another
  8. ... I'm getting an undefined JavaScript method call on their install page, so it won't let me download.
  9. I suppose I would specifically request effigy to answer my question, but I'm open to any suggestions at all at this point. I am working on a generic query handler for an open source application I am writing, and I want to know if there is an easy way to recognize table names from within a query string and replace them with a prefix. Since I am adding the functionality to an already existing table structure and application core, I am a bit too late to have the queries themselves written with the prefix in them (prefix may change upon installation). So, my issue comes to this: I need a reliable way to replace all occurrences of table names within a query with the prefix + table name, but ONLY in the parts of the query where they are indeed table names. So, if the table name appears within a string, we DO NOT want to replace it. Any suggestions? I've been playing around with breaking the parser down into different handlers for the different query syntax, but I'm not sure this is the easiest or most efficient way to go. I can even find the tables themselves with a match like this: (FROM|INTO|LOW_PRIORITY|IGNORE)(.+?)(WHERE|GROUP|HAVING|ORDER|LIMIT|\() But, that doesn't take care of WHERE, ORDER BY or even HAVING clauses, so I was hoping there was a way I might just match all occurrences of the table names not inside strings. I think this would be generic enough for my purposes. Ideas?
  10. In Windows, it's Scheduled Tasks.
  11. Which gets a full out 404 error ... heh. I guess we'll just have to wait for the official launch.
  12. So, everything I've read cites http://gears.google.com/chrome as the official download/information point (besides the Google blog, of course), and that link still kicks back to their home page. I can only hope that it is just a redirect until they're ready to launch the full download. I've been keeping my eye on this, and I'm very interested to get some "hands on" time with some of the functionality and integration with Gears and other Google tools. Definitely looks like a new dev toy to me!
  13. It really depends upon your goals. Are you looking to contract permanently, or are you looking to obtain a FT position in the field? Either way, your personal work ethic, abilities and experience will speak for themselves. Many times, you'll run into an HR department who was just told to hire a candidate with X degree, but those companies worth their salt usually will acknowledge that there is an equivalent work experience as well. For instance, I have a bachelor's degree, but it is in nothing remotely pertaining to my occupation as a web developer. Most companies with whom I have spoken over the years really couldn't care less about the degree based on my reputation with my prior clients and work. If you have relevant work experience, don't hesitate in posting for those jobs that cite a degree requirement. Often, you will find that they will be more than happy to waive that requirement in favor of a handful of solid years of experience. Now, you will still find those who are hesitant to consider you without the backing of a degree, so that leaves you with more responsibility to really prove yourself as a competent developer. Collect an impressive portfolio that you can use to sell them on your abilities. One of the most useful things I have been able to have is the verbal and/or written testimonials of previous clients. At one point, I sent out a mailer to my previous contacts and collected reviews on my work which I then used as references (since much of the work I have done has been on intranet sites and therefore impossible to include in a portfolio). People really seem to appreciate it when you have a glowing review These are just a few thoughts to keep in mind. Also, get some good connections on a professional site like LinkedIn. Recommendations on there also seem to boost your reputation among professionals. Good luck!
  14. If your sizes of the containing divs are always going to be fixed, a simple background image declaration is all that is needed: CSS: div.holder { background: url('your-background-image.jpg') no-repeat 50% 50%; /* centered in the background */ text-align: center; } HTML: <div class="holder"> <img src="my-image.jpg" /> <p>My Text</p> </div>
  15. I'm not sure why it would be returning 1, but a word of suggestion: why not preset all your variables and then just echo the variables into the value field instead of having to do your if statement for each? Try something like this: <?php $post_fields = array('yourname', 'email', 'phone'); foreach ($post_fields as $f) { // Don't forget to sanitize for output $$f = isset($_POST[$f]) ? htmlentities($_POST[$f], ENT_QUOTES) : ''; } ?> <input type="text" name="yourname" value="<?php echo $yourname; ?>" /> <input type="text" name="email" value="<?php echo $email; ?>" /> <input type="text" name="phone" value="<?php echo $phone; ?>" />
  16. <?php echo date('D, js', strtotime('08-08-08')); ?>
  17. Any time you feel your question has been answered thoroughly, please do mark the thread as solved. If you have additional questions or clarification later, you can always come back and post more or start a new thread. Good luck!
  18. There are a couple things to consider. First, if you are just doing the loop, you need to break out of the loop when the string is found. That way, you don't continue to process and report on the rest of the file when you have already found the result. Also, if you use a string search, you can avoid having to worry about breaking the string into pieces. Try something like this: <?php function fileSearch($filename, $string) { $handle = fopen($filename, 'r'); while (!feof($handle)) { $row = fgets($handle, 4096); $pattern = '|\b' . $string . '\b|'; // Check for word boundaries if (preg_match($pattern, $row)) { // Break out of the loop fclose($handle); return TRUE; } } return FALSE; // nothing was found } if (fileSearch('filename.txt', 'my-string')) { // String appears in document } ?> Of course, if your text files are not super long, you can always just get the whole thing as a string and then do your boundary search on it: <?php $string = 'abc'; $text = file_get_contents('filename.txt'); if (strstr($text, $string)) { // At least one occurrence found. } ?> Good luck!
  19. ROTFL ... I have some friends who do a Chuck Norris trip every summer through the national parks of the great northwest, and they usually do a blog of their misadventures chock full of classic Norris quotes. I'll have to add this one to their repertoire.
  20. What is "full"? If they are typical text fields and you have a static number of characters required by the field, you could have a JavaScript function like this to help: function jumpField(ele, max_chars, new_field_id) { if (ele.value.length >= max_chars) { document.getElementById(new_field_id); } } Then, you would add something like this to your input declaration: <input type="text" name="my_field" id="my-field" onkeyup="jumpField(this, 5, 'my-other-field');" maxlength="5" /> <input type="text" name="my_other_field" id="my-other-field" maxlength="5" /> Also, I'm moving this to the JavaScript forums since this is a client side question...
  21. Not so. If you want to group multiple actions into one onload call like this, you need to add your Custom.init() into the function declaration you mention: window.onload = function() { Custom.init(); // ... follow through with the rest of your code }
  22. Hahahahaha!!! Never met a server yet who couldn't give a good face kick when the need arises!
  23. [quote author=ProjectFear link=topic=106377.msg976533#msg976533 date=1219907446] He is doing the Clone Wars again, animated though. [/quote] The thing about that, though, is that it's not a new concept at all. The [i]Clone Wars[/i] style in the CGI movie is patterned after the Cartoon Network series that aired in three seasons from 2003 - 2005.
  24. Without parenthesis, AND takes precedence, so your code is actually seeing if: FID = $user->ID OR (ID = $user->ID AND type = 1) So, you need to set off the OR with parentheticals: <?php $buddys = "SELECT * FROM `" . DBPREFIX . "buddys` WHERE (`FID` = " . $user->ID . " OR `ID` = " . $user->ID . ") AND `Type` = '1'"; ?>
×
×
  • 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.