Jump to content

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


prakashghai

Recommended Posts

After spending 3 days on internet and struggling with so many different forums , i have found this forum where i believe i will get the solution for my problem.

 

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

 

    <?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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.