如何把下面的代码做成一个输入框加一个按钮,在输入框中输入数字后按钮执行代码!!
<?$conn=mssql_connect("192.168.2.254","sa","123");//链接SQLSERVER$dbname=mssql_select_d...
<?
$conn = mssql_connect("192.168.2.254","sa","123"); //链接SQL SERVER
$dbname = mssql_select_db("train") or die("数据库不存在或不可用".mssql_error()); //选择数据库
$sql = "select * from px_employee where empno =输入框位置"; //执行SQL语句
$result = mssql_query($sql);
echo "<table border=1>";
while($row = mssql_fetch_array($result)) //循环输出
{
$bumc = $row[8];
$ygbh = $row[4];
$ygmc = $row[5];
$zw = $row[9];
$pxmc = $row[2];
$pxsj = $row[10];
echo "<tr>";
echo "<td>$bumc</td>";
echo "<td>$ygbh</td>";
echo "<td>$ygmc</td>";
echo "<td>$zw</td>";
echo "<td>$pxmc</td>";
echo "<td>$pxsj</td>";
echo "</tr>";
}
echo "</table>";
?>
代码中(输入框位置)就是输入数字的地方! 展开
$conn = mssql_connect("192.168.2.254","sa","123"); //链接SQL SERVER
$dbname = mssql_select_db("train") or die("数据库不存在或不可用".mssql_error()); //选择数据库
$sql = "select * from px_employee where empno =输入框位置"; //执行SQL语句
$result = mssql_query($sql);
echo "<table border=1>";
while($row = mssql_fetch_array($result)) //循环输出
{
$bumc = $row[8];
$ygbh = $row[4];
$ygmc = $row[5];
$zw = $row[9];
$pxmc = $row[2];
$pxsj = $row[10];
echo "<tr>";
echo "<td>$bumc</td>";
echo "<td>$ygbh</td>";
echo "<td>$ygmc</td>";
echo "<td>$zw</td>";
echo "<td>$pxmc</td>";
echo "<td>$pxsj</td>";
echo "</tr>";
}
echo "</table>";
?>
代码中(输入框位置)就是输入数字的地方! 展开
1个回答
展开全部
在这个页面上修改如下:
<?
if(isset($_POST['dosubmit'])){
$conn = mssql_connect("192.168.2.254","sa","123"); //链接SQL SERVER
$dbname = mssql_select_db("train") or die("数据库不存在或不可用".mssql_error()); //选择数据库
$pos=$_POST['num'];
$sql = "select * from px_employee where empno ='$pos'"; //执行SQL语句
$result = mssql_query($sql);
echo "<table border=1>";
while($row = mssql_fetch_array($result)) //循环输出
{
$bumc = $row[8];
$ygbh = $row[4];
$ygmc = $row[5];
$zw = $row[9];
$pxmc = $row[2];
$pxsj = $row[10];
echo "<tr>";
echo "<td>$bumc</td>";
echo "<td>$ygbh</td>";
echo "<td>$ygmc</td>";
echo "<td>$zw</td>";
echo "<td>$pxmc</td>";
echo "<td>$pxsj</td>";
echo "</tr>";
}
echo "</table>";
}else{
?>
<form method="post">
<input type="text" name="num" value="" />
<input type="submit" name="dosubmit" value="提交" />
</form>
<?php
}
?>
<?
if(isset($_POST['dosubmit'])){
$conn = mssql_connect("192.168.2.254","sa","123"); //链接SQL SERVER
$dbname = mssql_select_db("train") or die("数据库不存在或不可用".mssql_error()); //选择数据库
$pos=$_POST['num'];
$sql = "select * from px_employee where empno ='$pos'"; //执行SQL语句
$result = mssql_query($sql);
echo "<table border=1>";
while($row = mssql_fetch_array($result)) //循环输出
{
$bumc = $row[8];
$ygbh = $row[4];
$ygmc = $row[5];
$zw = $row[9];
$pxmc = $row[2];
$pxsj = $row[10];
echo "<tr>";
echo "<td>$bumc</td>";
echo "<td>$ygbh</td>";
echo "<td>$ygmc</td>";
echo "<td>$zw</td>";
echo "<td>$pxmc</td>";
echo "<td>$pxsj</td>";
echo "</tr>";
}
echo "</table>";
}else{
?>
<form method="post">
<input type="text" name="num" value="" />
<input type="submit" name="dosubmit" value="提交" />
</form>
<?php
}
?>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询