Hello, it’s posible to transfer value on button like variable in function and call this function ?
<div style= "height: 400px;
width: 80%;
background-color: powderblue;
overflow:scroll;">
<?php
include 'config.php';
$sql ="SELECT * FROM playlist ORDER BY name DESC";
$result = $conn->query($sql);
if ( !empty($result->num_rows) && $result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$name = str_replace("\"","'", $row["name"]);
$song = "playlist1/".$name;
$key = $row["id"];
?>
<form method="post">
<button style= "width: 50px;" ><?php echo $row["point"] ?></button>
<button style= "width: 50px;" ><?php echo $row["playtimes"] ?></button>
<input type="submit" name="playnow"
class="button" value="<?php echo $id;?>" />
</form>
</br>
<?php
}
}
?>
</div>
<?php
function playnow(){
include 'config.php';
$sql = "UPDATE playlist SET playnow = 1 WHERE id = '$id'";
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
}
$conn->close();
?>
I want to send in function playnow value $id from button like $id in my function.