tjverge Posted February 6, 2011 Share Posted February 6, 2011 <head> <script language="javascript" type="text/javascript" src="datetimepicker.js"> </script> </head> <form action="main.php?id=test.php" method="post"> <p>Start Date: <input name="start" id="start" type="text" size="10"> <a href="javascript:NewCal('start','ddmmyyyy')"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a date"></a> End Date: <input name="end" id="end" type="text" size="10"> <a href="javascript:NewCal('end','ddmmyyyy')"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a date"></a> <input name="submit" type="submit" value="Look Up"> </form> <?php if(isset($_POST['submit'])) { $start = $_POST['start']; $end = $_POST['end']; $sql = "SELECT * FROM `corps` WHERE `notedate` BETWEEN '$start' AND '$end'"; $results = mysql_query($sql) OR DIE(mysql_error()); $numrow = mysql_num_rows($results) ; $i = 0; While ($i < $numrow) $shownotes = mysql_result($results,$i,'notes'); echo $shownotes."<br>"; { Echo "Records found ".$i."<br>"; $i++; } } The $start, and $end don't seem to be getting any values Quote Link to comment https://forums.phpfreaks.com/topic/226854-variable-not-passing-from-form/ Share on other sites More sharing options...
Pikachu2000 Posted February 6, 2011 Share Posted February 6, 2011 Add the 3 indicated lines, and see what exactly is in the post array. If they aren't there, disable javascript in your browser, enter something in the text fields and try it again. if(isset($_POST['submit'])) { echo '<pre>'; // <----- ADD print_r($_POST); // <----- ADD echo '</pre>'; // <----- ADD $start = $_POST['start']; $end = $_POST['end']; $sql = "SELECT * FROM `corps` WHERE `notedate` BETWEEN '$start' AND '$end'" Quote Link to comment https://forums.phpfreaks.com/topic/226854-variable-not-passing-from-form/#findComment-1170542 Share on other sites More sharing options...
tjverge Posted February 6, 2011 Author Share Posted February 6, 2011 Array ( [start] => 1-2-2011 [end] => 5-2-2011 [submit] => Look Up ) Fatal error: Maximum execution time of 30 seconds exceeded in /home5/ccccomma/public_html/test.php on line 29 Quote Link to comment https://forums.phpfreaks.com/topic/226854-variable-not-passing-from-form/#findComment-1170543 Share on other sites More sharing options...
tjverge Posted February 6, 2011 Author Share Posted February 6, 2011 Array ( [start] => 1-2-2011 [end] => 5-2-2011 [submit] => Look Up ) Fatal error: Maximum execution time of 30 seconds exceeded in /home5/ccccomma/public_html/test.php on line 29 Line 29 is: $shownotes = mysql_result($results,$i,'notes'); Quote Link to comment https://forums.phpfreaks.com/topic/226854-variable-not-passing-from-form/#findComment-1170544 Share on other sites More sharing options...
tjverge Posted February 6, 2011 Author Share Posted February 6, 2011 Ok got rid of the error but back to my first problem noting is showing up on the page <head> <script language="javascript" type="text/javascript" src="datetimepicker.js"> </script> </head> <form action="main.php?id=test.php" method="post"> <p>Start Date: <input name="start" id="start" type="text" size="10"> <a href="javascript:NewCal('start','ddmmyyyy')"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a date"></a> End Date: <input name="end" id="end" type="text" size="10"> <a href="javascript:NewCal('end','ddmmyyyy')"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a date"></a> <input name="submit" type="submit" value="Look Up"> </form> <?php if(isset($_POST['submit'])) { echo '<pre>'; // <----- ADD print_r($_POST); // <----- ADD echo '</pre>'; // <----- ADD $start = $_POST['start']; $end = $_POST['end']; $sql = "SELECT * FROM `corps` WHERE `notedate` BETWEEN '$start' AND '$end'"; $results = mysql_query($sql) OR DIE(mysql_error()); $numrow = mysql_num_rows($results) ; $i = 0; While ($i < $numrow) { $shownotes = mysql_result($results,$i,"notes"); echo $shownotes."<br>"; $i++; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/226854-variable-not-passing-from-form/#findComment-1170545 Share on other sites More sharing options...
Pikachu2000 Posted February 6, 2011 Share Posted February 6, 2011 What do you mean nothing is showing up? Blank screen, or just not the data you expected? Quote Link to comment https://forums.phpfreaks.com/topic/226854-variable-not-passing-from-form/#findComment-1170547 Share on other sites More sharing options...
tjverge Posted February 6, 2011 Author Share Posted February 6, 2011 well besides the Array ( [start] => 1-2-2011 [end] => 5-2-2011 [submit] => Look Up ) there are no records showing up, there are records that would match in the database table Quote Link to comment https://forums.phpfreaks.com/topic/226854-variable-not-passing-from-form/#findComment-1170548 Share on other sites More sharing options...
tjverge Posted February 6, 2011 Author Share Posted February 6, 2011 I may have an idea what the problem is the entered date format is DDMMYYYY, where as the mysql format is YYYYMMDD, I'm not sure how to convert it to match. Quote Link to comment https://forums.phpfreaks.com/topic/226854-variable-not-passing-from-form/#findComment-1170550 Share on other sites More sharing options...
Pikachu2000 Posted February 6, 2011 Share Posted February 6, 2011 Ah, then you should change the format the date picker sends it over in the $_POST array. Change ddmmyyyy to yyyymmdd and that should do it, if it's the same date picker I've used in the past. Quote Link to comment https://forums.phpfreaks.com/topic/226854-variable-not-passing-from-form/#findComment-1170552 Share on other sites More sharing options...
tjverge Posted February 6, 2011 Author Share Posted February 6, 2011 Ah, then you should change the format the date picker sends it over in the $_POST array. Change ddmmyyyy to yyyymmdd and that should do it, if it's the same date picker I've used in the past. I tried that I get "undefined" instead of a date Quote Link to comment https://forums.phpfreaks.com/topic/226854-variable-not-passing-from-form/#findComment-1170553 Share on other sites More sharing options...
tjverge Posted February 6, 2011 Author Share Posted February 6, 2011 Problem solved I added a new function to the JavaScript file and it works now thank you all Quote Link to comment https://forums.phpfreaks.com/topic/226854-variable-not-passing-from-form/#findComment-1170556 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.