我正在编写一个PHP页面,我希望在textbox
中显示SQL查询结果。我试着寻找答案,但我真的不明白它们。
这是我的问题:
SELECT MARK_TAB from disabled_tab where SCHOOL_CODE = 9999;
我想在这里显示查询:
Mark <input type="text" style="width: 30px;" id="marktab" />
我该怎么办?欣赏它:)
答案 0 :(得分:0)
$result = SELECT MARK_TAB from disabled_tab where SCHOOL_CODE = 9999;
在您的HTML中
<input type="text" style="width: 30px;" id="marktab" value="<?php echo $result;?>" />
答案 1 :(得分:0)
以此为例:
<?php
// connect to mysql stuff
$con = mysqli_connect("localhost","db_user","db_pass","database");
$query = mysqli_query($con, "SELECT MARK_TAB from disabled_tab where SCHOOL_CODE = 9999;");
$result = mysqli_fetch_assoc($query);
?>
<!-- echo that results on the value attribute -->
<input type="text" name="" value="<?php echo $result['MARK_TAB']; ?>" />
答案 2 :(得分:0)
试试这个:
<?php
$query = "SELECT MARK_TAB from disabled_tab where SCHOOL_CODE = 999"
$result = mysqli_query($connection,$query)
if($row = mysqli_fetch_assoc($query)
{
$yourvalue = $row['your_row'];
?>
<input type="text" style="width: 30px;" id="marktab" value="<?php echo $yourvalue?>"/>
<?php
}
?>php