使用php填充null数据,用mysql数据填充html表单 [英] Filling html forms with mysql data using php coming up null

查看:88
本文介绍了使用php填充null数据,用mysql数据填充html表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图填充一个html表单,数据从我的mysql数据库中接收。但是,我无法设置窗体显示正在加载从数据库中提取的变量。我希望载入的表单将最后输入的数据保存到之前添加到数据库中的表格中。

I am trying to fill a html form with data being received out of my mysql database. However I cannot set the forms to display on-load the variables being extracted from the database. I would like the form on-load to hold the data last entered into the forms which have been added to the database previously.

    $query = "SELECT FROM character_tbl WHERE character_player 

='".$_SESSION["user"]."' character_tbl";
    $result = mysql_query($query);
while($row = mysql_fetch_array($result)){  
$name = $row['character_name'];
$race = $row['character_race'];
$class = $row['character_class'];
$alignment = $row['character_alignment'];
$hp = $row['character_hp'];
$str = $row['character_str'];
$dex = $row['character_dex'];
$con = $row['character_con'];
$int = $row['character_int'];
$wis = $row['character_wis'];
$cha = $row['character_cha'];
$ac = $row['character_ac'];
$touch = $row['character_touch'];
$flat = $row['character_flat'];
$fort = $row['character_fort'];
$ref = $row['character_ref'];
$will = $row['character_will'];
}

echo $will;
mysql_close();


?>
<!DOCTYPE html>
<html>
<body>

<div id="nav">

<form action="user.php">
    <input type="submit" value="Back">
</form>
</div>

<div id="section">
<form action="update.php" method="POST">
  Character Name:<br>
  <input type="text" name="name" value="<?php echo $name;?>">
  <br>
  Race<br>
  <input type="text" name="race" value="<?php echo $race;?>">
  <br>
  Class<br>
  <input type="text" name="class" value="<?php echo $class;?>">
  <br>
  Alignment<br>
  <input type="text" name="alignment" value="<?php echo $alignment;?>">
  <br>
  HP<br>
  <input type="text" name="hp" value="<?php echo $hp;?>">
  <br>
  STR<br>
  <input type="number" name="str" value="<?php echo $str;?>">
  <br>
  DEX<br>
  <input type="number" name="dex" value="<?php echo $dex;?>">
  <br>
  CON<br>
  <input type="text" name="con" value="<?php echo $con;?>">
  <br>
  INT<br>
  <input type="text" name="int" value="<?php echo $int;?>">
  <br>
  WIS<br>
  <input type="text" name="wis" value="<?php echo $wis;?>">
  <br>
  CHA<br>
  <input type="text" name="cha" value="<?php echo $cha;?>">
  <br>
  AC<br>
  <input type="text" name="ac" value="<?php echo $ac;?>">
  <br>
  Touch AC<br>
  <input type="text" name="touch" value="<?php echo $touch;?>">
  <br>
  Flat-Footed AC<br>
  <input type="text" name="flat" value="<?php echo $flat;?>">
  <br>
  Fortitude<br>
  <input type="text" name="fort" value="<?php echo $fort;?>">
  <br>
  Reflex<br>
  <input type="text" name="ref" value="<?php echo $ref;?>">
  <br>
  Will<br>
  <input type="text" name="will" value="<?php echo $will;?>">
  </br>
  <input type="submit" value="Update">

</form>


推荐答案

你的mysql查询中有语法错误。您没有放置字段或列名称或( * )提取所有列。

You have syntax error in your mysql query. You have not place field or columns name or (*) for all columns to extract.

请尝试这样。 。

$query = "SELECT * FROM character_tbl WHERE character_player ='".$_SESSION['user']."'";

这篇关于使用php填充null数据,用mysql数据填充html表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆