Hello thanks for that, it worked great. I have another question about the same form and php page. How could we get the sql statement to return all rows which contain the first 3 numbers of whatever has been selected from the drop down list? So if 1990 is selected from the drop down on the form, it would return all rows which have 199 in the date column, so 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 as they all start with 199 Any help would be great Thanks Dave [!--quoteo(post=350035:date=Feb 27 2006, 10:49 PM:name=wickning1)--][div class=\'quotetop\']QUOTE(wickning1 @ Feb 27 2006, 10:49 PM) [snapback]350035[/snapback][/div][div class=\'quotemain\'][!--quotec--] The best answer depends on what TYPE you've set date to. $y3 = substr($_POST['date'], 0, 3); If it's a string type: "SELECT * FROM dates WHERE date LIKE '".$y3."%'" If it's an int type "SELECT * FROM dates WHERE date >= CAST ('".$y3."0' AS UNSIGNED) AND date <= CAST ('".$y3."9' AS UNSIGNED)" If it's a date type "SELECT * FROM dates WHERE date >= CAST ('".$y3."0' AS DATE) AND date <= CAST ('".$y3."9' AS DATE)" [/quote] Hi Date is a int I have put the following but it didnt like it [code]<? session_start(); include ("db.php"); $y3 = substr($_POST['year'], 0, 3); $sql ="SELECT * FROM dates WHERE date >= CAST ('".$y3."0' AS UNSIGNED) AND date <= CAST ('".$y3."9' AS UNSIGNED)"; $result = @mysql_query($sql,$connection) or die(mysql_error()); $num = mysql_num_rows($result); ?>[/code] I get the error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('2010' AS UNSIGNED) AND date <= CAST ('2019' AS UNSIGNED)' at line 1 Any ideas? Thanks Dave