到目前为止,我遇到了一个紧迫的问题,代码从数据库中获取结果,没问题,但是它沿着这条线散开!除了在一个清晰的html页面中显示,它只是将所有内容缩小到一端!像这样
我的意思是,什么错了?我似乎不明白为什么它将数据缩小到一端而水平线也是......没有完全显示...
这是我的源代码
<html>
<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<LINK href="C:/Users/Emi/Desktop/home.css" rel="stylesheet" type="text/css">
<title>Fees Register </title>
</head>
<body>
</div>
<div align="center">
<table border="0" width="84%" id="table1">
<tr>
<td> </td>
</tr>
<tr>
<td>
<img border="0" src="index_files/text827854609.gif" width="260" height="67"></td>
</tr>
<tr>
<td><hr size="4" color="#808080"></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>
<form method="POST" action="receipt_search.php" id="paymentsearchform" name="paymentsearchform">
<!--webbot bot="SaveResults" U-File="fpweb:///_private/form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p> Enter Student Name :
<input type="text" name="fullname" size="58">
<input type="submit" value="Search Payment Activity" name="sendx"></p>
</form>
<p></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><?php
include 'mysqlconn.php';
if(isset($_POST['sendx']))
{
$con = mysqli_connect($host, $dbuser, $pass, $db) or die('Connect Failed!');
$fullname = mysqli_real_escape_string($con,$_POST['fullname']);
$sql = "SELECT * FROM fees WHERE fullname = '$fullname'";
$result = mysqli_query($con,$sql) or die("Error: ".mysqli_error($con));
$tableheader = "<td>
<table border=0 width=100% id=table2 align=center>
<tr>
<td width=307 align=center>
<font face=Verdana size=2>Full Name </font></td>
<td width=198 align=center>
<font face=Verdana size=2> Guardians Name</font></td>
<td width=157 align=center>
<font face=Verdana size=2> Receipt </font></td>
<td align=center><font face=Verdana size=2> Purpose</font></td>
</tr>";
echo $tableheader;
while( $row = mysqli_fetch_array( $result, MYSQLI_ASSOC ) )
{
$tablerows = "<tr>
<td width=307 align=center>" . $row['fullname'] . "</td>
<td width=198 align=center>" . $row['gname'] . "</td>
<td width=157 align=center>" . $row['rNo'] . "</td>
<td align=center>" . $row['pwhy'] . "</td>
</tr>";
}
echo $tablerows;
}
?></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><hr size="4" color="#808080"></td>
</tr>
<tr>
<td><font face="Arial" size="1"></font></td>
</tr>
</table>
</div>
</body>
</html>
我确实需要帮助。
答案 0 :(得分:0)
请清理HTML,table
结构不好!
这是一个清洁版本。只需添加CSS。
<html>
<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<LINK href="C:/Users/Emi/Desktop/home.css" rel="stylesheet" type="text/css">
<title>Fees Register </title>
</head>
<body>
<div>
<form method="POST" action="receipt_search.php" id="paymentsearchform" name="paymentsearchform">
<!--webbot bot="SaveResults" U-File="fpweb:///_private/form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p>Enter Student Name :</p>
<p><input type="text" name="fullname" size="58"></p>
<p><input type="submit" value="Search Payment Activity" name="sendx"></p>
</form>
<?php
include 'mysqlconn.php';
if(isset($_POST['sendx']))
{
$con = mysqli_connect($host, $dbuser, $pass, $db) or die('Connect Failed!');
$fullname = mysqli_real_escape_string($con,$_POST['fullname']);
$sql = "SELECT * FROM fees WHERE fullname = '$fullname'";
$result = mysqli_query($con,$sql) or die("Error: ".mysqli_error($con));
$tableheader = "<table border=0 width=100% id=table2 align=center>
<tr>
<th width=307 align=center>
<font face=Verdana size=2>Full Name </font></th>
<th width=198 align=center>
<font face=Verdana size=2> Guardians Name</font></th>
<th width=157 align=center>
<font face=Verdana size=2> Receipt </font></th>
<th align=center><font face=Verdana size=2> Purpose</font></th>
</tr>";
echo $tableheader;
while( $row = mysqli_fetch_array( $result, MYSQLI_ASSOC ) )
{
$tablerows = "<tr>
<td width=307 align=center>" . $row['fullname'] . "</td>
<td width=198 align=center>" . $row['gname'] . "</td>
<td width=157 align=center>" . $row['rNo'] . "</td>
<td align=center>" . $row['pwhy'] . "</td>
</tr>";
}
echo $tablerows;
echo '</table>';
}
?>
</div>
</body>
</html>
答案 1 :(得分:0)
你的代码中有很多html问题:
<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<LINK href="C:/Users/Emi/Desktop/home.css" rel="stylesheet" type="text/css">
<title>Fees Register </title>
</head>
<body>
// I removed the closing div
<div align="center">
<table border="0" width="84%" id="table1">
<tr>
<td> </td>
</tr>
<tr>
<td>
<img border="0" src="index_files/text827854609.gif" width="260" height="67"></td>
</tr>
<tr>
<td><hr size="4" color="#808080"></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>
<form method="POST" action="receipt_search.php" id="paymentsearchform" name="paymentsearchform">
<!--webbot bot="SaveResults" U-File="fpweb:///_private/form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p> Enter Student Name :
<input type="text" name="fullname" size="58">
<input type="submit" value="Search Payment Activity" name="sendx"></p>
</form>
<p></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>
<?php
include 'mysqlconn.php';
if(isset($_POST['sendx']))
{
$con = mysqli_connect($host, $dbuser, $pass, $db) or die('Connect Failed!');
$fullname = mysqli_real_escape_string($con,$_POST['fullname']);
$sql = "SELECT * FROM fees WHERE fullname = '$fullname'";
$result = mysqli_query($con,$sql) or die("Error: ".mysqli_error($con));
//removed the td, you already opened it
$tableheader = "<table border='0' width='100%' id='table2' align='center'>// don't forget the quotes here
<tr>
<td width=307 align=center>
<font face=Verdana size=2>Full Name </font></td>
<td width=198 align=center>
<font face=Verdana size=2> Guardians Name</font></td>
<td width=157 align=center>
<font face=Verdana size=2> Receipt </font></td>
<td align=center><font face=Verdana size=2> Purpose</font></td>
</tr>";
echo $tableheader;
$tablerows = ""; // needed for later
while( $row = mysqli_fetch_array( $result, MYSQLI_ASSOC ) )
{
$tablerows .= "<tr>
<td width=307 align=center>" . $row['fullname'] . "</td>
<td width=198 align=center>" . $row['gname'] . "</td>
<td width=157 align=center>" . $row['rNo'] . "</td>
<td align=center>" . $row['pwhy'] . "</td>
</tr>";// if you use $tablerows = instead of $tablerows .= your line will always get overwritten
}
$tablerows .= "</table>"; // you need to close the table as well
echo $tablerows;
}
?></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><hr size="4" color="#808080"></td>
</tr>
<tr>
<td><font face="Arial" size="1"></font></td>
</tr>
</table>
</div>
</body>
</html>
这些修改在我测试时为我解决了这个问题。