我可以正确填充Dropbox,但是当我点击提交时,我找不到在表格中显示所选项目数据的方法。这是代码:
的index.php
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Αναζήτηση Οφειλών Ανά Πολυκατοικία</title>
<link rel="stylesheet" href="tbl_style.css" type ="text/css"/>
</head>
<body>
<form id="form1" name="form1" method="POST" action="search.php">
<?php
include('config.php');
$query = "SELECT DISTINCT odos FROM ofeiles_results ORDER BY odos ASC";
mysql_query("SET CHARACTER SET 'utf8'");
mysql_query("SET NAMES 'utf8'");
$result = mysql_query($query);
echo "<select name='polykatoikia'>";
while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['odos'] . "'>" . $row['odos'] . "</option>";
}
echo "</select>";
?>
<input type="submit" name="Submit" value="Select" />
</form>
</html>
</body>
到目前为止,Dropbox已经填满了。然后在search.php文件中我有以下代码:
的search.php
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Αποτελεσματα Αναζητησης Πολυκατοικιων</title>
<link rel="stylesheet" href="tbl_style.css" type ="text/css"/>
</head>
</html>
<?php
include('config_barcode.php');
if(isset($_POST['select'])){
$odoss = $_POST['select'];
mysql_query("SET CHARACTER SET 'utf8'");
mysql_query("SET NAMES 'utf8'");
$display_query = "SELECT odos FROM ofeiles_results WHERE odos LIKE '" . $odoss . "'";
$result_exoda = mysql_query($display_query) or die(mysql_error());
print $result_exoda;
$odos = $row['odos'];
$app = $row['perigrafh'];
$enoikos = $row['enoikos'];
$mhnas = $row['mhnas'];
$synolo = $row['synolo'];
echo "</br>";
echo "</br>";
echo "</br>";
echo "<table cellpadding='3' cellspacing='0'>";
echo "<tr>";
echo "<th align='center' bgcolor='#FFCC00'><strong>Οδος</strong></th>";
echo "<th align='center' bgcolor='#FFCC00'><strong>Διαμερισμα</strong></th>";
echo "<th align='center' bgcolor='#FFCC00'><strong>Όνομα</strong></th>";
echo "<th align='center' bgcolor='#FFCC00'><strong>Σύνολο</strong></th>";
echo "<th align='center' bgcolor='#FFCC00'><strong>Μήνας</strong></th>";
echo "</tr>";
echo "<td align='center'>".$odos."</td>";
echo " <td align='center'>".$app."</td>";
echo " <td align='center'>".$enoikos."</td>";
echo " <td align='center'>".$mhnas."</td>";
echo " <td align='center'>".$synolo."</td>";
echo "</table></td>";
echo $result_exoda;
}
?>
我得到的只是一个空白页面。我究竟做错了什么?感谢。
答案 0 :(得分:0)
我用这个来显示表中的数据,你不需要使用很多“echo”使用LOOPS 你可以在
中添加更多行$sql = "SELECT your_row , another_row , your_row_again FROM your_table_name";
如果您的数据库中有更多行。
$conn = mysql_connect($dbhost, $dbuser);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
$sql = "SELECT your_row , another_row , your_row_again FROM your_table_name";
mysql_select_db('your_db');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not get data: ' . mysql_error());
}
echo "<div align = 'center'><table border = '1'>";
echo "<th>Your_row_Header</th><th>Row_Header_again</th><th>Row_Header_again</th>";
while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
{
echo "<tr><td align = center>{$row['Your_row1']}</td>".
"<td align = center>{$row['Your_Row2']}</td></tr>".
"<td align = center>{$row['Your_Row3']}</td>";
}
echo "</table></div><br />";
mysql_close($conn);