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.