Jump to content
Larry Ullman's Book Forums

HartleySan

Members
  • Posts

    3047
  • Joined

  • Last visited

  • Days Won

    243

Everything posted by HartleySan

  1. I'm having a lot of trouble following your code. I think it would help if you used the <> button in the editor to better format and color code everything. As a general answer to your question though, you can either pass back true/false from the subfunctions to the main function and return that, or you can have an independent Boolean, whose value is calculated based on some sort of condition(s). I know that probably doesn't help much, but without cleaning up your code more, there isn't much we can do to help.
  2. NULL and an empty string are two different things. An empty string means that there is a value, but that value is nothing, whereas NULL is the absence of a value. As such, depending on your data and what it's being used for, you need to make the determination for which you think is best in which scenario. This may offer further info: http://programmers.stackexchange.com/questions/32578/sql-empty-string-vs-null-value As for setting NULL in SQL, when you send the parameters to your PHP script, if something is set to an empty string, then you have to set it to NULL. If you're using a regular mysqli_execute function call, then the following is one way of handling it: $param1 = $_POST['param1'] !== '' ? $_POST['param1'] : 'NULL';
  3. Placeholder text is more to inform the user of the type of input they should provide than anything else.
  4. This should answer your question: http://www.w3schools.com/jsref/prop_text_defaultvalue.asp Short answer: defaultValue checks the value attribute, not the placeholder one.
  5. Click on the .ZIP file link: http://www.larryullman.com/books/php-and-mysql-for-dynamic-web-sites-visual-quickpro-guide-4th-edition/#downloads
  6. It's nothing, really. I just have more familiarity with JS than most people. Anyway, enjoy the rest of your holidays.
  7. Hello and welcome to the forums. In my opinion, this is still the best book for getting started with PHP/MySQL. Virtually everything in it is still relevant, and most importantly, it'll give you that great base, which is very easy to build on and use to then learn all of the most recent best practices. In short, don't delay any longer. Start reading and writing code, as this is still the best PHP/MySQL book around.
  8. First off, localhost is local only to you, meaning that the URL you posted will not work for anyone else. More importantly than that though, you need to change index.html to index.php and then run the script through a server. Do you have XAMPP or some other server software installed?
  9. The thing you're talking about is a WYSIWYG editor, and the one used on this site is CKEditor, which is probably the most popular one. You can get it for free here: http://ckeditor.com/ Also, TinyMCE is quite popular.
  10. It's pretty simple to do what you want. The first thing to do is load the initial images for each product on the page. This is basic HTML. Once that's done, then use JS to load all the images that are used when a color swatch is moused over. All of those extra images can be simply loaded into the DOM and hidden, or "displayed" but hidden out of the bounds of an element with overflow: hidden, etc. Point being, there are any number of ways to hide all the other images, but have them readily available for swapping in and out. Also, when the page loads, you'll want to set up mouseover event handlers for each of the color swatches, and then swap the currently displayed image out with the moused-over image each time a color swatch is hovered over. Again, there are any number of specific implementations that are possible here, but the general principle is the same. Lastly, if you want to support smartphones and tablets, know that they don't support mouseover events, so you'll have to set up a click event for the swatches on mobile. Hopefully that answers your questions.
  11. It's because the second argument you're passing to the function is a string literal, not a regular expression literal. In PHP, you have to declare regexes as strings, but in JS, regexes have their own type (and should not be surrounded by quotes). You would only ever use a string for a regex in JS if you're using the RegExp constructor, which you're not. Short answer: If you want to do a regex literal, which I assume you do, take the quotes off the second parameter being passed to the function. That will fix that error. As for the error message you're getting, you're getting it because there is no test method for strings in JS, just regexes.
  12. I worked as a developer for about eight months for a fairly larger online clothing vendor, and as far as I could tell, they had an entire marketing team that decided which picture/color should be the default for each product. Of course, below the main image for a product were the color swatches, which you could click on any one of them to switch the color/image displayed. I guess the point is, if you're a small operation and don't have the time/money to invest in such things, just pick whatever you think is best, or always have it be black, etc., or have it be random. Truth be told, while I'm not in expert in that sort of thing, that seems like the kind of optimization that is probably not worth worrying about during the initial building of your site.
  13. I'm a bit unclear on what you're asking, but are you talking about something like the following, where you have one big image and smaller thumbnail images you can click on to make them the big image? http://www.zappos.com/puma-no-1-logo-tee-athletic-grey-heather-black-marshmallow
  14. Somewhere in your script, run the following: echo '<pre>'; print_r($_SERVER); echo '</pre>'; Pay attention to the the request URL parameters, and compare them. They should reveal the actual URLs being used, and from there, you can hopefully resolve the issue.
  15. If window is undefined, then there is definitely some really weird stuff going on. Unfortunately, without more knowledge of your code and setup, it's hard to help. My guess though, is that an error farther up the script is causing the script to shut down midstream.
  16. There's no right answer, but always using curly braces is (I think) clearer, more consistent and makes your code easier to read. Furthermore, I think Larry recommends that in the JS book in particular because the most popular JS code checking tool, JSLint, will throw an error if you don't use curly braces every time.
  17. angel, what errors, if any, are showing up in your browser console? Thanks.
  18. Buttercream, just try to relax a bit. It wasn't a bad question to ask, I was just simply stating that it's not really a question that can be easily answered based on my experience. If you want to know the truth, the best thing you can do is not act like you just did in your previous post. Your previous post sounded a bit on the immature side (and please excuse me if I misinterpreted what you wrote). If you want to get a job as a developer, learn the trade well (but you don't need to be an expert), and then apply for jobs in your area, and if you score an interview, go in there and be professional and confident. If you really want to be a developer, the first job is all about getting your foot in the door and building up experience and connections, even if you don't like the job that much or it doesn't pay well.
  19. While I personally don't like JSFiddle (and I while I was being a bit facetious in my remark about JSFiddle), it's not a bad prototyping tool. As long as you're aware of its limitations, etc., you can still use it to get you 90% there.
  20. No, what I mean is, if you run the following query on the DB (with actual values), how many records are returned? SELECT COUNT(i.invention_id), c.category_id FROM inventions AS i INNER JOIN categories AS c USING (category_id) WHERE category_id = $cat;
  21. In my opinion, it's impossible to generalize your questions into meaningful answers. I think you're best to look at the local job listings and talk to some local recruiters to get a better idea of what is actually available in your area. If you see something close to what you want, then I would then inquire into part-time possibilities, etc.
  22. Probably because JSFiddle sucks. But in all seriousness, I imagine that any code you type into the JSFiddle textarea is going to behave slightly differently than regular JS. Edit: Here's the answer: http://stackoverflow.com/questions/5468350/javascript-not-running-on-jsfiddle-net
  23. Did you set up the Ruby interpreter? Did you download the tutorial package? In other words, did you do all the steps between the first few commands and executing "git init"?
×
×
  • Create New...