timetomove Posted August 2, 2006 Share Posted August 2, 2006 PHP Freaks Forums Hello timetomove August 02, 2006, 03:37:05 pm *Show unread posts since last visit.Show new replies to your posts.Total time logged in: 3 minutes.News: We have DITCHED Invisionboard and converted to SMF. There are issues with signatures and some posts. Please do your best to help cleanup around here and move the conversion along. Home Help Search Profile My Messages Members Logout PHP Freaks Forums > PHP Discussions > PHP SQL > Start new topicUsing Date from PHP dropdown form in mySQLHi there.How about this one then??I was wondering if anyone knew why this isnt working. I think its an error in my syntax, maybe a missing " or something?HuhHuh??While checking the availability of rental cars on a date.I'm trying to pass a choosen date from a dropdown form into a mySQL statement.The statement doesnt seem to be reading the $date variable. Any suggestions would be GREATLY appreciated.THE FORM:<form id="date_form" action="availability_action.php"><select name="day"><optgroup label="Day"><?phpfor ($i=1; $i <= 31; $i++) { echo "<option value=\"$i\">$i</option>"; }?></optgroup></select><select name="month"><optgroup label="Month"><?phpfor ($i=1; $i <= 12; $i++) { echo "<option value=\"$i\">$i</option>"; }?></optgroup></select><select name="year"><optgroup label="Year"><?phpfor ($i=2000; $i <= 2010; $i++) { echo "<option value=\"$i\">$i</option>"; }?></optgroup></select><input type="submit" value="Go!" /></div></form>THE ACTION:$date = $_POST['year'].str_pad($_POST['month'], 2, '0', STR_PAD_LEFT).str_pad($_POST['day'], 2, '0', STR_PAD_LEFT);$results = mysql_query("SELECT carFROM car_tableLEFT JOIN booking_table ON car_table.car = booking_table.carWHERE $date NOTBETWEEN booking_table.startAND booking_table.end")OUTPUT RESULTS:while ($row = mysql_fetch_assoc($results)) { $output .= '<tr>'."\n"; $output .= '<td class="col_1">'.$row['car'].'</td>'."\n"; $output .= '</tr>'."\n"; }The output is showing ALL the cars in the car_table and not paying any attention to my $date variable!I hope Ive described my problem clearly and really would be most grateful if anyone could give me any pointers. I tried concetenating .'115959' onto the end of the $date parameters as my dates are in yyyymmddhhmmss format but I wasnt sure if that was neccessary.. it didnt do anything.Thanks,Tim Quote Link to comment Share on other sites More sharing options...
fenway Posted August 2, 2006 Share Posted August 2, 2006 Please post the echoed output of the query string itself. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.