jacko_162 Posted May 8, 2010 Share Posted May 8, 2010 As above, i have a page that pulls down information from the database and graphs said information using the google graph code. next i want to make a page with 2x date selectors, and the page shows information from database within that range. problem is i dont know a great deal about PHP so im after some sample coding snippets i can use, or if somone can help me out with where to look. not sure if i should use the from and to date in the URL and when running the sql query to fetch the data from the URL to perform the sql commands. Quote Link to comment https://forums.phpfreaks.com/topic/201125-selecting-database-information-in-a-date-range/ Share on other sites More sharing options...
paddyhaig Posted May 8, 2010 Share Posted May 8, 2010 Mmmm, so I tried it up on my Linux server and not so good!~ What can this mean? Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home1/oninacom/public_html/concierge/scripts/authenticate/auth.php on line 12 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home1/oninacom/public_html/concierge/scripts/authenticate/auth.php on line 17 Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home1/oninacom/public_html/concierge/scripts/authenticate/auth.php:12) in /home1/oninacom/public_html/concierge/scripts/authenticate/auth.php on line 20 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home1/oninacom/public_html/concierge/scripts/authenticate/auth.php:12) in /home1/oninacom/public_html/concierge/scripts/authenticate/auth.php on line 20 Quote Link to comment https://forums.phpfreaks.com/topic/201125-selecting-database-information-in-a-date-range/#findComment-1055188 Share on other sites More sharing options...
jacko_162 Posted May 8, 2010 Author Share Posted May 8, 2010 Mmmm, so I tried it up on my Linux server and not so good!~ What can this mean? Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home1/oninacom/public_html/concierge/scripts/authenticate/auth.php on line 12 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home1/oninacom/public_html/concierge/scripts/authenticate/auth.php on line 17 Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home1/oninacom/public_html/concierge/scripts/authenticate/auth.php:12) in /home1/oninacom/public_html/concierge/scripts/authenticate/auth.php on line 20 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home1/oninacom/public_html/concierge/scripts/authenticate/auth.php:12) in /home1/oninacom/public_html/concierge/scripts/authenticate/auth.php on line 20 confused... wrong post? Quote Link to comment https://forums.phpfreaks.com/topic/201125-selecting-database-information-in-a-date-range/#findComment-1055191 Share on other sites More sharing options...
PFMaBiSmAd Posted May 8, 2010 Share Posted May 8, 2010 jacko_162, which part of this do you need help with? It is not a php problem until the form has been submitted and the two date values have been received on the server. Once the two values are on the server, the php form processing code would need to validate them, format them as yyyy-mm-dd values to match your column values in your database table, escape them to prevent sql injection, and put them into a WHERE clause in a query using the BETWEEN ... AND ... comparison. If the problem is creating the form to input or select them, you must define what method you went to use to enter or pick them and also what format they will be entered as. Quote Link to comment https://forums.phpfreaks.com/topic/201125-selecting-database-information-in-a-date-range/#findComment-1055195 Share on other sites More sharing options...
jacko_162 Posted May 8, 2010 Author Share Posted May 8, 2010 thank you for reply, i have the form made and upon selecting the date range and clicking submit it enters the URL as follows: test.php?graph_start=November+9%2C+2009&graph_end=May+9%2C+2010 i can then echo the variables just fine. i enter the date format into the database across the site as: $todaydate = date("F j, Y"); which outputs May 9, 2010 when echo'd. problem i need help with is the mysql query. i need to select * from table "BETWEEN HE ABOVE VARIABLES IN URL" i also need a helping hand with echoing the variable; <?php echo $graph_start; ?> - WORKS FINE but if i echo $graph_start and it returns nothing, i.e nothing in URL can i echo "NO DATE" Quote Link to comment https://forums.phpfreaks.com/topic/201125-selecting-database-information-in-a-date-range/#findComment-1055205 Share on other sites More sharing options...
jacko_162 Posted May 9, 2010 Author Share Posted May 9, 2010 i fixed my echoing variable command; <?php $end = $_GET['graph_end']; if ($end) { echo "$end"; } else { echo "$todaydate"; } ?> all i need now is help creating a SQL command to pull data between the 2x date variables. Quote Link to comment https://forums.phpfreaks.com/topic/201125-selecting-database-information-in-a-date-range/#findComment-1055214 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.