Jump to content
Larry Ullman's Book Forums

HartleySan

Members
  • Posts

    3047
  • Joined

  • Last visited

  • Days Won

    243

Posts 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. 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.

  4. 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.

  5. 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.

    • Upvote 1
  6. 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.

    • Upvote 1
  7. 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.

×
×
  • Create New...