我想在h1标签中使用员工姓名。任何人都可以告诉我们如何做到这一点。有关详细信息,请参阅评论说明。
<html>
<head>
<title>Employee Data</title>
</head>
<body>
<h1>Employee Name is _______ </h1> //I want to display employee name here
<?php
error_reporting(0);
include('config.php');
$qry = "SELECT * FROM emp_data where eName='dinesh'";
$result = mysql_query($qry) or die (mysql_error());
echo '<table cellpadding="0" cellspacing="0" class="edb-table">';
while($row=mysql_fetch_array($result))
{
echo "<tr><td>Name:</td><td><a href='emp_name.php?name=" . $row['emName'] . "'>".$row['emName'] . "</a></td></tr>";
echo "<tr><td>Date of Birth:</td><td>".$row['emDOB'] . "</a></td></tr>";
echo "<tr><td>Department:</td><td>".$row['emDepart'] . " </td></tr>";
}
echo "</table>";
mysql_close();
?>
</body>
</html>
答案 0 :(得分:0)
正如Dagon建议的那样:
<?php
error_reporting(0);
include('config.php');
$table_content = "";
$employee_name = "";
$qry = "SELECT * FROM emp_data where eName='dinesh'";
$result = mysql_query($qry) or die (mysql_error());
while($row=mysql_fetch_array($result))
{
$employee_name = $row['emName'];
$table_content .= "<tr><td>Name:</td><td><a href='emp_name.php?name=" . $row['emName'] . "'>".$row['emName'] . "</a></td></tr>";
$table_content .= "<tr><td>Date of Birth:</td><td>".$row['emDOB'] . "</a></td></tr>";
$table_content .= "<tr><td>Department:</td><td>".$row['emDepart'] . " </td></tr>";
}
mysql_close();
?>
<html>
<head>
<title>Employee Data</title>
</head>
<body>
<h1>Employee Name is <?php echo $employee_name; ?></h1>
<table cellpadding="0" cellspacing="0" class="ddb-table">
<?php echo $table_content; ?>
</table>
</body>
</html>