21,886
社区成员
发帖
与我相关
我的任务
分享
<?php
$q=$_POST["employeenumber"];
$con = mysql_connect('localhost', 'root', '');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("org", $con);
echo "<table border='1' cellpadding='10'>
<tr>
<th>架构</th>
<th>盈利额</th>
</tr>";
$sql="SELECT 架构,盈利额 FROM `org` WHERE 主管工号 = '".$q."'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['架构'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?><br>
<html>
<body>
欢迎
<?php
$q=$_POST["employeenumber"];
$con = mysql_connect('localhost', 'root', '');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("org", $con);
$sql="SELECT 姓名 FROM user WHERE 员工号 = '".$q."'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
echo $row['姓名'];
echo '<form name="form1" method="post" action="add.php">';
echo "<table border='1' cellpadding='10'>
<tr>
<th>架构</th>
<th>盈利额</th>
</tr>";
$sql="SELECT id,架构,盈利额 FROM `org` WHERE 主管工号 = '".$q."'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['架构'] . "</td>";
echo '<td><input type="number" name= '.$row['id'].'></td>';
echo "</tr>";
}
echo "</table>";
echo '<input type="hidden" name="employeenumber" value="'.$q.'">';
echo '<input type="submit" value="提交指标">';
mysql_close($con);
?><br>
</body>
</html>
add.php
<html>
<head>
</head>
<body>
<?php
$con = mysql_connect('localhost', 'root', '');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("org", $con);
$employeenumber = $_POST["employeenumber"];
$sql="SELECT id, 架构,盈利额 FROM `org` WHERE 主管工号 = '".$employeenumber."'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
if($_POST[$row['id']]){
$sqlstr = "update `org` set 盈利额='".$_POST[$row['id']]."' where id='".$row['id']."' and 主管工号 = '".$employeenumber."'"; // 更新入db
mysql_query($sqlstr) or die(mysql_error());
}
}
mysql_close($con);
echo "指标提交成功";
?>
</body>
</html>
还是很感谢各位的帮助。
if($_POST[.$row['id'].]){
$sqlstr = "update `org` set 盈利额='" . $_POST[.$row['id'].] . "' where id='".$row['id']."'";// 更新入db
mysql_query($sqlstr) or die(mysql_error());
}
$sqlstr = "update `org` set 盈利额='" . $_POST['yl'.$row['id']] . "' where id='".$row['id']."'";
<html>
<title>指标收集系统</title>
<body>
<center><form action="welcome.php" method="post">
工号: <input type="text" name="employeenumber" placeholder="请输入7位工号"><br>
密码: <input type="password" name="password"><br>
<input type="submit" value="登录">
</form></center>
</body>
</html>
welcome.php
<html>
<body>
欢迎
<?php
$q=$_POST["employeenumber"];
$con = mysql_connect('localhost', 'root', '');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("org", $con);
$sql="SELECT 姓名 FROM user WHERE 员工号 = '".$q."'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
echo $row['姓名'];
echo '<form name="form1" method="post" action="add.php">';
echo "<table border='1' cellpadding='10'>
<tr>
<th>架构</th>
<th>盈利额</th>
</tr>";
$sql="SELECT id,架构,盈利额 FROM `org` WHERE 主管工号 = '".$q."'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['架构'] . "</td>";
echo '<td><input type="number" name="yl'.$row['id'].'"></td>';
echo "</tr>";
}
echo "</table>";
//echo '<input type="hidden" name="employeenumber" value="'.$q.'">';
echo '<input type="submit" value="提交指标">';
mysql_close($con);
?><br>
</body>
</html>
add.PHP
<html>
<head>
</head>
<body>
<?php
$con = mysql_connect('localhost', 'root', '');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("org", $con);
//$employeenumber = $_POST["employeenumber"];
$sql="SELECT id, 架构,盈利额 FROM `org` WHERE 主管工号 = '".$q."'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
if($_POST['yl'.$row['id']]){
$sqlstr = "update `org` set 盈利额='"$_POST['yl'.$row['id'].]"' where id='".$row['id']."'"; // 更新入db
mysql_query($sqlstr) or die(mysql_error());
}
}
mysql_close($con);
//header('location:welcome.php?q='.$q); // 跳轉回去
?>
</body>
</html>
现在运行后出现错误:Parse error: syntax error, unexpected T_VARIABLE in D:\AppServ\www\add.php on line 24
请问怎么解决?
<?php
$q=$_POST["employeenumber"];
$con = mysql_connect('localhost', 'root', '');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("org", $con);
echo '<form name="form1" method="post" action="add.php">';
echo "<table border='1' cellpadding='10'>
<tr>
<th>架构</th>
<th>盈利额</th>
</tr>";
$sql="SELECT id, 架构,盈利额 FROM `org` WHERE 主管工号 = '".$q."'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['架构'] . "</td>";
echo '<td><input type="text" name="yl'.$row['id'].'"></td>';
echo "</tr>";
}
echo "</table>";
echo '<input type="hidden" name="employeenumber" value="'.$q.'">';
echo '</form>';
mysql_close($con);
?>
add.php
<?php
$con = mysql_connect('localhost', 'root', '');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("org", $con);
$employeenumber = $_POST["employeenumber"];
$sql="SELECT id, 架构,盈利额 FROM `org` WHERE 主管工号 = '".$q."'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
if($_POST['yl'.$row['id']]){
$sqlstr = "update `org` set 盈利额='".$_POST['yl'.$row['id']]."' where id='".$row['id']."'"; // 更新入db
mysql_query($sqlstr) or die(mysql_error());
}
}
mysql_close($con);
header('location:index.php?q='.$employeenumber); // 跳轉回去
?>