Well, I'm back with yet another question about PHP + MySQL. This time its getting a variable to work in a WHERE clause. The database holds comic page filenames and the date they are to be released on the website. I want the artist to be able to upload and register (in the database) as many pages as he wants. The filenames arre formatted with the date of release, like this - 20090718.png - this is the day of release lets say. I convert this to a unix timestamp so I can manipulate and format it in varios programmatical ways later. This SQL works in my code quite easily. I have a script to INSERT now I need to get it back in various ways.
CODE
$sql = "SELECT comic_filename, comic_date FROM comic ORDER BY comic_date DESC"
Even though the whole comic might be listed in the database, comics are released twice a week. I want all comics equal to or less than the current date to be available. Future comics stay hidden until there time. Users can step forwards and backwards through the VALID list of comics. I tried this SQL and it didn't work.
CODE
sql = "SELECT comic_filenames, comic_date FROM comic ORDER BY comic_date DESC WHERE comic_date <= '$today'";
I've tried $today with and without the single quotes - single quotes around variables in my INSERT statement worked... The value of $today is also a timestamp for the current day. If a filename has this as its release date then that is a valid comic and can be displayed. Again, I want the resultset to include the current day's timestamp value and below.
If this sounds confusing I can try to elaborate on it in more detail but really it comes down to using PHP variables in my WHERE clause. Also, is this the proper way to get the results I want. I use the data in the table to display the correct comic page to users on the site and they can step through the pages sequentially.
Any and all help is greatly appreciated. The books I have mention every other kind of situation but fall short of a really good hands-on about PHP and MySQL - the little things you have to know to pull off what you want to do. Thanks in advance.
