gpt4 book ai didi

php - 用于将答案存储在数组中并更改按钮的颜色

转载 作者:行者123 更新时间:2023-11-28 01:48:42 25 4
gpt4 key购买 nike

当答案保存在数据库中但未保存时,此代码应更改按钮颜色。请帮助我是一个初学者。

<?php 
$qpquery="SELECT COUNT(id) AS total FROM question WHERE FMid=$tid";
$qprs=mysqli_query($conn,$qpquery) or die("database error:". mysqli_error($conn));
if ($qprs->num_rows > 0) {
while($qpro = $qprs->fetch_assoc()) {
$total=$qpro["total"];
}
echo $total;
}
for ($j = 1 ; $j <= $total; $j++)
{
?>


<?php echo $_SESSION['mark_ques'][$j];
foreach($_SESSION['mark_ques'] as $storeanswer){
$flag = 0;
if ($storeanswer == $j){
$flag = 1;
break;
}
}
if($flag == 1){?>

<button type="button" class="button button5" style="background-color:Green;">
<?php echo $j ; ?> </ton>

代码链接- https://drive.google.com/file/d/108XgWQFwCqJz3y58g9SN1nu6NfbbjLKG/view?usp=sharing

最佳答案

我建议你用 javascrpit 试试,试试这个:

  <button id="MyButton" type="button" class="button button5">

<?php

if($flag == 1){?>
<script>
document.getElementById("MyButton").style.background = "green";
</script>
<?php } ?>

关于php - 用于将答案存储在数组中并更改按钮的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50066940/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com