0
<?php

$servername = "localhost";
    $username = "root";
    $password = "";
    $dbname = "asd";

    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection

    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }

$i=0;
$name="Vishnu";
?> 

<?php
    for($i=0;$i<5;$i++)
    {
?>
<button onclick="myFunction()">Click me

<?php
    $ni=$name.$i;
    echo "</br>Name is $ni</br>";
    echo "</br>Roll number is $i</br>";
    echo "</br></br>";
}
?>
</button>

<?php

function myFunction()
{

echo "</br>AAAA</br>";
}
?>

This code doesn't prints the output from the function for any button. I want to print the value from the function whenever I click on any of the button. Is it possible to make such an implementation ?

Vishnu
  • 1

0 Answers0