1

I have buttons with names from database displayed on my browser, what I want to achieve is to display the documents' requirement in a hidden div which is toggled through the buttons. The thing is I don't know how I attempted to use ajax but seems so complicated and it makes me confused. So I'm just looking for the simplest that it can be. And I think it could be jQuery which is to be used but I just dont know how to make functions and combine it with php. Can anyone help me with this.

This is my code that displays the document's name and the button.

<div id="sidebar">
    <h3>Request Documents</h3>

    <ul class="">
    <?php 
        include_once 'dbconnect.php';
        $query = "SELECT d.document_id,d.document_name
                    FROM document_tbl AS d";

        if (!$result = mysql_query($query)) {
            exit(mysql_error());
        }

        // if query results contains rows then featch those rows 
        if(mysql_num_rows($result) > 0) {

            while($row = mysql_fetch_assoc($result)){
                echo'<li class="">
                    <p><button onclick="readRecords('.$row['document_id'].')" class="btn btn-info btn-lg">'.$row['document_name'].'</button></p>
                    </li>';
            }
        }
    ?>

    </ul>
</div>

I just don't know what to do with the rest.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user
  • 45
  • 1
  • 8
  • Every time you use [the `mysql_`](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) database extension in new code **[a Kitten is strangled somewhere in the world](http://2.bp.blogspot.com/-zCT6jizimfI/UjJ5UTb_BeI/AAAAAAAACgg/AS6XCd6aNdg/s1600/luna_getting_strangled.jpg)** it is deprecated and has been for years and is gone for ever in PHP7. If you are just learning PHP, spend your energies learning the `PDO` or `mysqli` database extensions. [Start here](http://php.net/manual/en/book.pdo.php) – RiggsFolly Sep 18 '16 at 14:44
  • You are basically asking us to write a sizable chunk of code for you. Sorry but **SO != free coding service** – RiggsFolly Sep 18 '16 at 14:47
  • Sorry, I'm aware of it but I think it can't somewhat help to my question. – user Sep 18 '16 at 15:09

0 Answers0