Hope the tittle fits my question.
I made a loop to display data from table and it is showed as buttons.
<?php
$a=0;
while($row = mysql_fetch_assoc($execute)){
$ID = $row['id'];
$name[] = $row['names'];
echo "<button name=\"btn$ID\" class='btnName' onClick='showForm()'>$name[$a]</button>";
$a++;
}
<div id="result" style="display: none;">
//name from clicked buttons should be displayed here
</div>
?>
And here is the function:
<script type="application/javascript">
function showForm(){
document.getElementById('result').style.display="block";
}
</script>
The 'id' field is only an incremented field. If I click the button, I want to display the name I click from one of those buttons in the result div.
How do I call it?
mysql_*-functions. They have been deprecated since PHP 5.5 (in 2013) and were completely removed in PHP 7 (in 2015). Use MySQLi or PDO instead.