因此,我尝试将数据库中的表中的值提取到html输入元素的占位符中。代码如下:
<input type="text" name="timesats" placeholder="
<?php
include($_SERVER['DOCUMENT_ROOT'].'/paycheck/scripts/connect.php');
$user = $_SESSION['user'];
$sql = "SELECT timesats WHERE email='$user'";
$query= mysqli_query($dbc,$sql);
$result = mysqli_fetch_object($query);
echo($result);
?>
">
$dbc
包含连接值。
我没有错误,所以很难调试。表中的值不为空。
答案 0 :(得分:0)
尝试
<?php
include($_SERVER['DOCUMENT_ROOT'].'/paycheck/scripts/connect.php');
$user = $_SESSION['user'];
$sql = "SELECT timesats WHERE email='$user'";
$query= mysqli_query($dbc,$sql);
while ($obj = mysqli_fetch_object($query)) {
$ph = $obj->timesats;
}
?>
<input type="text" name="timesats" placeholder="<?php echo $ph; ?>"/>