输入框输入,自动及时从数据库中读取数据并显示出来 - 老马资料库

输入框输入,自动及时从数据库中读取数据并显示出来

类别:程序开发 时间:2023-01-24 01:55:11 点击:298

<table>

<tr>

<td>会员编号:</td>

<td><input type="text" name="uid" value="" id="uid" onchange="che()" >* 非会员请填0</td>

</tr>

<tr>

<td>用户名:</td>

<td><input type="text" disabled value="" id="username" ></td>

</tr>

</table>


------------------


<script>

function che() {

    var userid = $("#uid").val();

$.post("us.php",{userid: userid},

    function(data){

$("#username").val (data);

        document.getElementById("sub").innerHTML = "<input type='submit' value='确定会员'>";

    })

};

</script>


-------------------


<?php

include('connn.php');

$userid = $_POST['userid'];

if ($userid==0){

echo "非用户";

}

$resultvb=mysql_fetch_assoc(mysql_query("select user_name from user where user_id='$userid'"));

if ($resultvb['user_name']){

echo $resultvb['user_name'];

}else{

echo "无此用户";

}

?>