bobicles2 Posted February 3, 2010 Share Posted February 3, 2010 I have this code <?php $sql="select * from Events where issue = (select max(issue) from jfs);"; $result_set = pg_Exec ($conn, $sql); $rows = pg_NumRows($result_set); if ((!$result_set) || ($rows < 1)) { echo "<H1>ERROR - no rows returned</H1><P>"; exit; //exit the script } $previous_issue = ""; for ($j=0; $j < $rows; $j++) { $issue = pg_result($result_set, $j, "issue"); $page = pg_result($result_set, $j, "page"); $author = pg_result($result_set, $j, "author"); $title = pg_result($result_set, $j, "title"); $url = pg_result($result_set, $j, "url"); ?> That pulls up "todays issue" from the table...but im looking to change it so that it pulls up items in the database with todays date. i.e - an issue with the date 15/02/10 would be displayed on the screen on that date only... $sql="select * from Events where issue = (select max(issue) from jfs);"; i know its the above part i need to alter but im not really sure how If anyone has any other advice id be grateful im doing this for a school project so im aware its very basic but i honestly appreciate all advice as for me its all part of the learning curve and im keen to improve! Thanks in advance Rob Quote Link to comment https://forums.phpfreaks.com/topic/190824-sql-query-for-retrieving-todays-date/ Share on other sites More sharing options...
dmikester1 Posted February 3, 2010 Share Posted February 3, 2010 Is issue a "date" in your database? Are you storing a date in the database for each issue? Quote Link to comment https://forums.phpfreaks.com/topic/190824-sql-query-for-retrieving-todays-date/#findComment-1006309 Share on other sites More sharing options...
Mchl Posted February 3, 2010 Share Posted February 3, 2010 http://www.postgresql.org/docs/8.0/interactive/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT Quote Link to comment https://forums.phpfreaks.com/topic/190824-sql-query-for-retrieving-todays-date/#findComment-1006310 Share on other sites More sharing options...
bobicles2 Posted February 3, 2010 Author Share Posted February 3, 2010 issue us a varchar not date in my table....however, i can easily change i just used varchar to test my database was working! im not sure what date input is....is it 00/00/00? or like 00/00/0000? thanks rob Quote Link to comment https://forums.phpfreaks.com/topic/190824-sql-query-for-retrieving-todays-date/#findComment-1006316 Share on other sites More sharing options...
dmikester1 Posted February 3, 2010 Share Posted February 3, 2010 Well, you need to get today's date using PHP's Date function. http://php.net/manual/en/function.date.php Then do a "select issue from database" making sure the two dates are in the same format and compare for equality. Mike Quote Link to comment https://forums.phpfreaks.com/topic/190824-sql-query-for-retrieving-todays-date/#findComment-1006319 Share on other sites More sharing options...
bobicles2 Posted February 3, 2010 Author Share Posted February 3, 2010 got it working using CURRENT_DATE just need to alter the html part now so the form input can only be in format 0000-00-00 so this doesnt mess up! thanks for all the help guys! this forum never lets me down ! Quote Link to comment https://forums.phpfreaks.com/topic/190824-sql-query-for-retrieving-todays-date/#findComment-1006334 Share on other sites More sharing options...
bobicles2 Posted February 3, 2010 Author Share Posted February 3, 2010 Now to find the HTML Form information... not sure if it exists sad times! Quote Link to comment https://forums.phpfreaks.com/topic/190824-sql-query-for-retrieving-todays-date/#findComment-1006342 Share on other sites More sharing options...
dmikester1 Posted February 3, 2010 Share Posted February 3, 2010 I don't know if you know any JQuery, but JQuery's Datepicker is wonderful for this sort of thing. And you can of course change the format of the date in the options. Check it out. http://jqueryui.com/demos/datepicker/ Mike Quote Link to comment https://forums.phpfreaks.com/topic/190824-sql-query-for-retrieving-todays-date/#findComment-1006343 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.