RE: [PHP] can't get it to work

From: Date: Wed, 03 Apr 2002 20:28:18 +0000
Subject: RE: [PHP] can't get it to work
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-91389@lists.php.net to get a copy of this message
Why not "SELECT .... WHERE date_field<$max_date and date_field>$min_date" ? A very god advice for everyone of you who tries to implement PHP for the where selects: You can VERY OFTEN leave this job to the DB itself. SQL don't only have SELECT, UPDATE etc... they all have lots of functions for the data comparisons and output formatting. Take some time reading the manuals and you will discover a whole new world on the RDBMS use. Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) maxim@phpbeginner.com www.phpbeginner.com > -----Original Message----- > From: Alex [mailto:aarmis@hotmail.com] > Sent: Wednesday, April 03, 2002 8:19 PM > To: php-general@lists.php.net > Subject: [PHP] can't get it to work > > I'm trying to write code that will return all records found between certain > dates(e.g. 2001-01-30 through 2002-01-30). I created a html form with pull > down menus for both dates but when I try to run it I get a parse error and > can't figure out what's wrong. > > Thanks, > > Alex > > Here is the php code: > > $month_1 = addslashes($date_month_1); > $day_1 = addslashes($date_day_1); > $year_1 = addslashes($date_year_1); > $month_2 = addslashes($date_month_2); > $day_2 = addslashes($date_day_2); > $year_2 = addslashes($date_year_2); > > > $query = SELECT * FROM table where date >= '$month_1/$day_1/$year_1' AND > date <= '$month_2/$day_2/$year_2'; > > $result = mysql_query($query); > > $num_results = mysql_num_rows($result); > > echo "<p>Number of records found: ".$num_results."</p>"; > > for ($i=0; $i <$num_results; $i++) > { > $row = mysql_fetch_array($result); > echo "<p><strong>".($i+1).". ID: "; > echo stripslashes($row["id"]); > echo "</strong><br>First name: "; > echo stripslashes($row["fname"]); > echo "<br>Last name: "; > echo stripslashes($row["lname"]); > } > > ?> > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#91389) next »