Friends, I am zero in PHP, but still i have managed to do something to fulfill my requirement.
I am stuck with one thing now..So i need help on....
I am using one html+php form to submit database into mysql.
I created a display of that table through php script on a webpage.
Now i want a datepicker option on that displayed page by which i should able to select the date range and display the data of that date range from my mysql table.
And then take a export of data displayed of selected date range in excel.
This displayed page is login protected, so i want after login the next thing comes in should show a sate selection option which should be fromdate to to date , and then records should displayed from the database and i can take export of those displayed results in excel file.
The code i am using on this page is below which do not have any thing included for excel export and datepicker script, I am pasting the code here and request you to please include the required code in it as required.
Thanks In advance
Expand|Select|Wrap|Line Numbers
- <?php
- //database connections
- $db_host = 'localhost';
- $db_user = '***********';
- $db_pwd = '*************';
- $database = 'qserves1_uksurvey';
- $table = 'forms';
- $file = 'export';
- if (!mysql_connect($db_host, $db_user, $db_pwd))
- die("Can't connect to database");
- if (!mysql_select_db($database))
- die("Can't select database");
- // sending query
- $result = mysql_query("SELECT * FROM {$table} ORDER BY date desc");
- if (!$result) {
- die("Query to show fields from table failed");
- }
- $num_rows = mysql_num_rows($result);
- $fields_num = mysql_num_fields($result);
- echo "$num_rows";
- echo "<h1></h1>";
- echo "<table border='1'><tr>";
- // printing table headers
- for($i=0; $i<$fields_num; $i++)
- {
- $field = mysql_fetch_field($result);
- echo "<td>{$field->name}</td>";
- }
- echo "</tr>\n";
- // printing table rows
- while($row = mysql_fetch_row($result))
- {
- echo "<tr>";
- // $row is array... foreach( .. ) puts every element
- // of $row to $cell variable
- foreach($row as $cell)
- echo "<td>$cell</td>";
- echo "</tr>\n";
- }
- mysql_free_result($result);
- ?>
- </body></html>