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

时间:2018-09-03 18:44:14

标签: php html pdo

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

2 个答案:

答案 0 :(得分: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>

答案 1 :(得分: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>