PDA

View Full Version : PHP help


Porn Junkie
2007-07-14, 03:56 AM
I need to write a select statement that basically pulls records out for the current date. Kind of what link lists use to show the days current selections.

I use <?php echo(date('F j, Y'))?> in my submit form but can't seem to figure out how to do a select to retrieve just todays submissions.

I thought this would work but it doesn't. $query_rsfeatured = "SELECT * FROM tsoomain WHERE tsoomain.ldate='<?php echo(date('F j, Y'))?>'";

HELP |banghead|

JK
2007-07-14, 08:05 PM
Try something like this, define the date first. No coffee in my system yet so it might not work.

$date = date('F j, Y');

$query_rsfeatured = "SELECT * FROM tsoomain WHERE tsoomain.ldate=$date";

$result = mysql_query($query_rsfeatured);

Porn Junkie
2007-07-15, 06:14 AM
worked like a freakin charm!

Greatly appreciated JK :)

AcidMaX
2007-07-19, 10:56 AM
Other options are:

SELECT * FROM tablename WHERE date = now();

OR

SELECT * FROM tablename WHERE date BETWEEN '2007-06-01 00:00:00' AND '2007-06-01 23:59:59'

really depends on your database structure. Always multiple ways to skin a cat.

Tinkerbell
2007-07-26, 01:39 AM
Just to explain why it is what you did, didn't work... The <?PHP and ?> tags are used to tell your server that what lies between them is going to be PHP code. The thing is, given that you had a variable, $query_rsfeatured, in your script already, you probably had those tags somewhere else before and after the code you quoted above. Placing another pair between those tags would produce an error. In other words, if you've already written <?PHP somewhere, you don't need to write it again until you've closed the first one with ?>.