473,414 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

PHP Script for Datepicker to slect and display database from Mysql required

After spending 3 days on internet and struggling with so many different forums , i have found a match and similar case of my problem here.

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
  1. <?php
  2.     //database connections
  3.     $db_host = 'localhost';
  4.     $db_user = '***********';
  5.     $db_pwd = '*************';
  6.  
  7.     $database = 'qserves1_uksurvey';
  8.     $table = 'forms';  
  9.     $file = 'export';
  10.     if (!mysql_connect($db_host, $db_user, $db_pwd))
  11.         die("Can't connect to database");
  12.  
  13.     if (!mysql_select_db($database))
  14.         die("Can't select database");
  15.  
  16.     // sending query
  17.     $result = mysql_query("SELECT * FROM {$table} ORDER BY date desc");
  18.     if (!$result) {
  19.         die("Query to show fields from table failed");
  20.     }
  21.     $num_rows = mysql_num_rows($result);
  22.     $fields_num = mysql_num_fields($result);
  23.  
  24.     echo "$num_rows"; 
  25.     echo "<h1></h1>";
  26.     echo "<table border='1'><tr>";
  27.     // printing table headers
  28.     for($i=0; $i<$fields_num; $i++)
  29.     {
  30.         $field = mysql_fetch_field($result);
  31.         echo "<td>{$field->name}</td>";
  32.     }
  33.     echo "</tr>\n";
  34.     // printing table rows
  35.     while($row = mysql_fetch_row($result))
  36.     {
  37.         echo "<tr>";
  38.  
  39.         // $row is array... foreach( .. ) puts every element
  40.         // of $row to $cell variable
  41.         foreach($row as $cell)
  42.             echo "<td>$cell</td>";
  43.  
  44.         echo "</tr>\n";
  45.     }
  46.     mysql_free_result($result);
  47.     ?>
  48.     </body></html>
Apr 3 '11 #1
0 1336

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: * Tong * | last post by:
or I have to be in some mlist in order to post? thanks -- Tong (remove underscore(s) to reply) *niX Power Tools Project: http://xpt.sourceforge.net/ - All free contribution & collection
6
by: Clay Beatty | last post by:
When you create database diagrams in Enterprise Manager, the details for constructing those diagrams is saved into the dtproperties table. This table includes an image field which contains most of...
1
by: Richard Galli | last post by:
I have a shopping cart with an automatic installation script. Add a new database without tables, configure the script with the table's user/password, and it's supposed to set up all the tables in...
0
by: Administrator | last post by:
Hello guys Just wanted to let you know that we added a new web gateway t *mailing.database.mysql* at TechieGroups.co From our web site you can read and reply to messages posted in thi group...
3
by: SS | last post by:
Hi, I don't want to refresh a web page to query and display database. I want the page shows information immediately when database changes. What kind of technology or method would be able to...
2
by: Parasyke | last post by:
A new problem has me puzzled. I have what appears to be a very stable database but suddenly I can't find my Database Window. I tried the Startup option of Display Database Window and hit the...
6
by: Ted | last post by:
I am construvcting a number of databases, some of which contain sensitive data and most of which do not. I am attempting to handle the security issues involved in protecting sensitive data in part...
1
by: ariel gons | last post by:
This is one of my project and also my thesis in school. How can I get data on database MYSQL using javascript function? Is there anybody here can help me with this problem.. Can anyone give...
1
by: Niraj175 | last post by:
How we can insert a value in database using database MySql for datatype LongText?
7
by: Surag | last post by:
Hello Guys, I have a datbase with userid,username and password. I Need to display database values in textboxes say for eg(Name and password) and redirect to login page based on the UserID please...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.