函数执行按钮在php中单击

时间:2017-03-13 09:51:29

标签: php function button

<?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>";
}
?>

此代码不会打印任何按钮的函数输出。每当我点击任何一个按钮时,我想从函数中打印出来的值。是否可以进行这样的实现?

0 个答案:

没有答案