gpt4 book ai didi

php - 如何从数据库中获取值

转载 作者:太空宇宙 更新时间:2023-11-03 10:29:06 25 4
gpt4 key购买 nike

我想从数据库中获取值..例如,在名称字段中,它显示存储在数据库中的名称。我想在各自的字段中显示值。但它无法检索值..plz 伙计们..帮助我

<?php 
session_start();
$username = $_SESSION["username"];
$department = $_SESSION["department"];

?>
<html>
<head>
<title>Change Password</title>

</head>

<form method="post" action="changepassprocess.php">
<?php
$db = mysql_connect('localhost','root')
or die ("unable to connect");
mysql_select_db('fyp',$db) or die ("able to select");

$sql_select = "SELECT * FROM access WHERE username ='".$username."' ";
?>

<font face= "arial" size="2" font color="black">
<center>
<h3 align=center> Change Password </h3>
<table width="500" height="100" border="0" cellspacing="0" cellpadding="2">

<tr>
<tr>
<td align="left">User ID</td>
<td>: <input name="username" type="text" id="username" value="<? {echo "$username"; } ?>" size="20" maxlength="10" readonly='username'></td>
</tr>

<tr>
<td align="left">Name </td>
<td>: <input name="name" type="text" id="name" value="<? {echo "$name"; } ?>" size="50" readonly="name"></td>
</tr>

<tr>
<td align="left">Department </td>
<td>: <?php echo $row['department']; ?> </td>
</tr>

<tr>
<td align="left">New Password </td>
<td>:<input name="newpassword" type="password" id="newpassword" size="20" ></td>
</tr>

</table><br>
<align = center><input type="submit" name="send" value="Change Password">
</form>
</body>
</html>

最佳答案

好吧,您忘记了对数据库运行查询。 $sql_select 变量保存查询文本,但您需要将其传递给数据库并从中检索答案。阅读http://php.net/manual/en/function.mysql-query.php和那里的例子。

关于php - 如何从数据库中获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2347387/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com