按钮不在“eco”标签内显示其值

问题描述 投票:-1回答:2

enter image description here

while(($res =  $statement->fetch(PDO::FETCH_ASSOC)) && ($c<$row)) {
    $c=$c+1;
    echo"<tr style='color:#00284d;font-size:15px;';>
                            <td style='background-color:#00284d;color:white;width:30px;'>{$c}</td>
                            <td>{$res['user_id']}</td>
                            <td>{$res['user_name']}</td>
                            <td>{$res['user_type']}</td>
                            <td><button type='button' name='edit' id='edit' **value='".$res['user_id']."'** class='btn btn-warning btn-sm' style='width:72px;'/></td>
                            <td><button type='button' name='delete' id='delete' value='".$res['user_id']."'  class='btn btn-danger btn-sm' onclick='asd();' style='width:72px;'/></td>
    // not display button inside value, always display 1 (display mean actually i checked what is the its value using javascript) 
    </tr>";
    }
}
?>
php html pdo
2个回答
0
投票

只需改变这段代码就像其他代码一样。

这是要改变的代码

<td><button type='button' name='edit' id='edit' **value='".$res['user_id']."'** class='btn btn-warning btn-sm' style='width:72px;'/></td>
<td><button type='button' name='delete' id='delete' value='".$res['user_id']."'  class='btn btn-danger btn-sm' onclick='asd();' style='width:72px;'/></td>

像这样

<td><button type='button' name='edit' id='edit' class='btn btn-warning btn-sm' style='width:72px;' value='{$res['user_id']}'>{$res['user_id']}</button> </td>
<td><button type='button' name='delete' id='delete' value='{$res['user_id']}'  class='btn btn-danger btn-sm' onclick='asd();' style='width:72px;' value='{$res['user_id']}'>{$res['user_id']}</button></td>

2
投票

您需要将文本放在<button></button>标记之间

<button type='button' name='edit' id='edit' **value='".$res['user_id']."'** class='btn btn-warning btn-sm' style='width:72px;'>EDIT</button>

<button type='button' name='delete' id='delete' value='".$res['user_id']."'  class='btn btn-danger btn-sm' onclick='asd();' style='width:72px;'>
    DELETE
</button>
© www.soinside.com 2019 - 2024. All rights reserved.