Jump to content

AmandaF

Members
  • Posts

    40
  • Joined

  • Last visited

    Never

Everything posted by AmandaF

  1. Nightslyr, thanks for the jQuery link. I don't think I'll be using it in this specific situation (a 56k js library just so I can use one function seems like overkill), but it is something I'd like to look into in the future. (What made you choose jQuery over another library, like prototype? I've been meaning to get around to learning about the various js libraries out there, and it seems like jQuery and prototype are the two most popular.) Ken, thanks, I'll try that out and let you know if it works. I wonder if part of the problem could be that, rather than using display:none, I'm using position:absolute;left:-999em;height:0; I've been doing that so that screenreader users will still hear the menu options, even though sighted users won't see them.
  2. It depends on how it affects the readability of the code. As far as the interpreter is concerned, the included/required file is part of the script, just like if you had cut and pasted the contents of the file into your main file, so there's no technical reason not to use variables from it. I'd suggest not using variables from the included file if you can help it, though, since it makes the code less readable. (Someone who is skimming your code and doesn't bother to open the included file will have no idea where the variable came from). As for the while loop, there's also no technical reason not to use variables that were created in them, but it's not a good idea from a logic standpoint. If circumstances are such that the loop never executes, you'll end up trying to use a variable that never gets defined. I'd just define the variable with a default value before writing the loop, to be on the safe side. Then you can use the variable however you want. Hope that helps.
  3. Sorry. The site isn't live yet and I don't know if my boss is ok with me posting our code on a message board.
  4. what data are you typing in the text inputs when you fill out the form? I don't see anything wrong with your code (now that you've included the curly braces). Try echoing the form values by themselves first on solution_a_php.php to see if the problem is the values themselves (e.g. does $_POST['verb1'] print nothing by itself?) or if the problem is the string you're injecting them into. (e.g. echo $_POST['verb1'] produces the correct value, but echo "One day while I was {$_POST["verb1"]}" does not). That should help narrow the problem down.
  5. I'm having a problem with some js code on a site. The site's menu is an unordered list, and some list items contain nested lists (submenus) which are supposed to be hidden from the user unless the user mouses over them (or tabs onto them from the keyboard). The css class that hides the submenus is applied to them within the js when the page loads, rather than hard-coding the class name into the html itself, because I want the submenus to be accessible to users who have css enabled and javascript disabled. (these users will see the menu fully expanded.) Problem is, the expanded list flashes briefly when the page first loads, before the javascript kicks in. I tried brothercake's solution (http://www.brothercake.com/site/resources/scripts/domready/) but it didn't help. (I also tried decreasing the interval time in his function, but it didn't have much of an effect.) Every other solution I've found on the internet either assumes that it's an IE problem (I'm having the problem with Firefox on a Mac) or involves coding practices that I try to avoid. (putting js directly in the html, doing things that would invalidate my strict xhtml 1.0, etc.) Any suggestions?
  6. Static methods are methods that can be accessed without being associated with a specific object. (If I understand correctly, there isn't a whole lot of difference between making a static method and making a non-OO function). Abstract methods are something else entirely. They're methods that haven't been implemented (in other words, the method has a name but no code) inside abstract classes. Other classes inherit these classes and implement the methods. To borrow a metaphor from this site, you might have classes representing dog breeds, all of which inherit from the abstract "dog" class with an abstract "bark" method. Bark() may be implemented differently depending on the class (some dogs "yip", others "woof", etc) but all classes inheriting the dog class must have a bark method. It's basically a way of making sure that similar objects have similar functionality.
  7. In addition to what Maq said, it looks like you're calling the same variable $game_id in one spot and $id in another. (Or are they supposed to be two separate variables?)
  8. Did a bit more research and it looks like only ID attributes are limited the way I described. Name attributes can be any valid xhtml characters (so basically everything except < > and &). I'm going to mark this thread as solved, but if anyone has anything to add, please post a reply.
  9. OK, thanks. Just wanted to make sure I wasn't making a faux pas by not adhering to a specific commenting style.
  10. It's only matching one character. /[a-z0-9]/i means "match anything that contains a letter or number". What you want is /^[a-z0-9]*$/i or /^[a-z0-9]+$/i which will match either zero or more (if you use the *) or one or more (with the +) letters and numbers in between the beginning (^) and end ($) of the string (so nothing but letters and numbers will be accepted).
  11. I'm hoping to eventually be able to write code that I could make available as open source. (Should I have posted this in the application forum instead?) Taking into consideration that random developers I've never met might read the code, is there a specific format that's preferred in the PHP community? One reason why I was interested in phpdoc was because it seemed like a standard (like how javadoc is a standard format for Java). Of course, if there isn't any reason to use phpdoc, then I'll stick to short and to the point comments. Thanks.
  12. I'm attempting to make the transition from being a ColdFusion programmer who writes small, procedural scripts to a PHP programmer who writes well-organized OO applications. One of the biggest hurdles I've run into is figuring out a clean, consistent way of documenting my code. I've tried using phpdoc syntax, and I find that I end up with comments that are significantly larger than the functions themselves. Is this something that's supposed to happen, a flaw in the phpdoc syntax, or just me being a newbie? Also, I could be wrong about this, but I'm under the impression that you're supposed to comment every class variable and method within the class. What about ones that have self-explanatory names? I don't really need a phpdoc block to explain that getFoo() returns the value of $foo, right? (hypothetical example, by the way. My variables have better names than $foo, hence the question! )
  13. This isn't really a regex issue. You just need to put the download link inside an if statement that has a condition checking if the file can be downloaded. Something like: if($row['FileID']) { echo "<td><a href='get_file.php?id=". $row['FileID'] ."'>Download</a></td>"; } else { echo '<td></td>'; } (Of course, that assumes that the FileID evaulates to false if there's no file. If that's not the case, you'll need to change it to whatever it should be.) Hope that helps.
  14. I'm writing a php script that involves generating an input element for an xhtml form, and I wanted it to throw an error if the arguments for the name, id, or class attribute of the element isn't valid for xhtml 1.0 strict. The official specification (http://www.w3.org/TR/xhtml1/), as far as I can tell, only gives a definition for ID fragments, not the full id attribute. Unofficial sites (blogs, forums, etc) seem to say that IDs and names are a letter followed by one or more letters, numbers, hyphens, underscores, colons and periods. (i.e. /[a-z0-9][-a-z0-9_:.]*/i) If that's the case, doesn't that mean the syntax for making a name attribute an array in php is invalid? (e.g. name="foo[]" is invalid). For that matter, wouldn't that make fragments invalid? (e.g. <a name="#foo">)
  15. There's a pretty good join tutorial here: http://www.phpfreaks.com/tutorial/data-joins-unions You want something similar to: select p.*, hs.*, t.*, pos.*, ppos.* from p join p using player_id join ppos using player_id join hs using mlbteam_id where ppos.position_id = 6 and hs.year = 2007 order by player_id, hr desc Granted, that probably has some errors in it and you'll need to fix the table names, but it should give you a basic idea to start with. Hope that helps.
×
×
  • 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.