使用MySQL在PHP中填充dropbox,然后在单击submit按钮后在表中显示数据
我可以正确填充dropbox,但在单击submit时找不到在表中显示所选项目数据的方法。代码如下: index.php使用MySQL在PHP中填充dropbox,然后在单击submit按钮后在表中显示数据,php,mysql,dropbox,Php,Mysql,Dropbox,我可以正确填充dropbox,但在单击submit时找不到在表中显示所选项目数据的方法。代码如下: index.php <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Αναζήτηση Οφειλών Ανά Πολυκατοικία</title>
<!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>
<!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;
}
?>
Αναζήτηση Οφειλών Ανά Πολυκατοικία
我使用它来显示表中的数据,您不需要使用许多“echo”use循环
可以在中添加更多行
$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);
$conn=mysql\u connect($dbhost,$dbuser);
如果(!$conn)
{
die('无法连接:'.mysql_error());
}
$sql=“从您的\u表\u名称中再次选择您的\u行、另一个\u行、您的\u行”;
mysql_选择_数据库(“您的_数据库”);
$retval=mysql\u查询($sql,$conn);
如果(!$retval)
{
die('无法获取数据:'.mysql_error());
}
回声“;
回显“您的行标题再次出现在行标题中”;
而($row=mysql\u fetch\u数组($retval,mysql\u ASSOC))
{
回显“{$row['Your_row1']}”。
“{$row['Your_Row2']}”。
“{$row['Your_Row3']}”;
}
回声“
”;
mysql_close($conn);
空白页面会建议您关闭错误检查或显示。不要使用mysql\uuz
函数,而是使用PDO。