我正在为包装数据库创建一个搜索表单,并使用 CSS 来设置调用 PHP 页面的 HTML 表单的样式。我希望能够使用与搜索表单样式相同的 CSS 来设置来自 PHP 页面的所有结果的样式,因为 PHP 继续将结果作为单独的元素回显,我希望所有这些结果都显示在单独的小框中。它是否像我认为的那样简单,例如只是用标签包围 PHP?正如我目前正在尝试的那样,但它似乎不起作用。
<body>
<?php
$con = mysql_connect ("localhost", "root", "");
mysql_select_db ("delyn_db", $con);
if (!$con)
{
die ("Could not connect: " . mysql_error());
}
$descrip = mysql_real_escape_string($_POST['descrip']);
$depth = mysql_real_escape_string($_POST['depth']);
$varWidth = mysql_real_escape_string($_POST['traywidth']);
$varHeight= mysql_real_escape_string($_POST['trayheight']);
$varRange = mysql_real_escape_string($_POST['trayrange']);
$varType = mysql_real_escape_string($_POST['traytype']);
$varShape = mysql_real_escape_string($_POST['trayshape']);
$varImage = mysql_real_escape_string($_POST['imagename']);
if (isset($varHeight) && !empty($varHeight)) {
$low = ($varHeight."00");
$high = ($varHeight."99");
} else {
$low = ("000");
$high = ("999");
}
if (isset($varWidth) && !empty($varWidth)) {
$min = ($varWidth."00");
$max = ($varWidth."99");
} else {
$min = ("000");
$max = ("999");
}
$sql = "SELECT * FROM delyn WHERE
description LIKE '%".$descrip."%'
AND trayrange LIKE '%".$varRange."%'
AND traytype LIKE '%".$varType."%'
AND trayshape LIKE '%".$varShape."%'
AND traywidth BETWEEN '".$min."' AND '".$max."'
AND trayheight BETWEEN '".$low."' AND '".$high."' ";
?>
while ($row = mysql_fetch_array($r_query))
{
echo '<p class="results">';
echo '<br /><img src=" '. $row['imagename'] . '" width="120" length="50">';
echo '<br /><strong> Tool Code: </strong> '. $row['toolcode'];
echo '<br /><strong> Description: </strong> '. $row['description'];
echo '<br /><strong> Tray range: </strong> '. $row['trayrange'];
echo '<br /><strong> Tray type: </strong> '. $row['traytype'];
echo '<br /><strong> Tray size: </strong> '. $row['traysize'];
echo '<br /><strong> Tray shape: </strong> '. $row['trayshape'] . '<br />' . '<br />' . '</p>';;
}
if (mysql_num_rows($r_query) <= 0){
echo 'No results match your search, please try again';
}
?>
</body>
CSS(对于 HTML 表单,我希望 Form div 标签的相同属性适用于结果):
@charset "UTF-8";
/* CSS 文档 */
body {
}
.results {
width: 190px;
padding: 10px;
background: #E8CF24;
overflow:auto;
display:block;
font-family: Verdana, Geneva, sans-serif;
font-size: 11px;
border: 1px solid #cccccc;
-moz-border-radius: 7px;
-webkit-border-radius: 7px;
border-radius: 7px;
-moz-box-shadow: 2px 2px 2px #cccccc;
-webkit-box-shadow: 2px 2px 2px #cccccc;
box-shadow: 2px 2px 2px #cccccc;
}
现在编辑。