jbrill Posted July 14, 2007 Share Posted July 14, 2007 Im trying to sort some queries form the database, heres the code: [code <? //already connected to database //get these variables from the URL $employee = $_GET['employee']; $fromdate = $_GET['fromdate']; $todate = $_GET['todate']; $allresultssql = "SELECT * FROM workhours WHERE name='".$employee."' AND BETWEEN date='".$fromdate."' AND date='".$todate."'"; $allresults = mysql_query($allresultssql); $results = mysql_fetch_array($allresults); ?> why will this not work? Link to comment https://forums.phpfreaks.com/topic/59969-simple-question-why-isnt-this-working/ Share on other sites More sharing options...
AndyB Posted July 14, 2007 Share Posted July 14, 2007 Why won't it work? Because your query syntax is wrong! Example: http://www.webdevelopersnotes.com/tutorials/sql/tutorial_mysql_in_and_between.php3 Link to comment https://forums.phpfreaks.com/topic/59969-simple-question-why-isnt-this-working/#findComment-298256 Share on other sites More sharing options...
redarrow Posted July 14, 2007 Share Posted July 14, 2007 try that allresultssql = "SELECT * FROM workhours WHERE name='".$employee."' AND date='".$fromdate."' BETWEEN date='".$todate."'"; Link to comment https://forums.phpfreaks.com/topic/59969-simple-question-why-isnt-this-working/#findComment-298259 Share on other sites More sharing options...
Barand Posted July 14, 2007 Share Posted July 14, 2007 That's as bad as the original. $allresultssql = "SELECT * FROM workhours WHERE name = '$employee' AND date BETWEEN '$fromdate' AND '$todate' "; Link to comment https://forums.phpfreaks.com/topic/59969-simple-question-why-isnt-this-working/#findComment-298281 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.