【发布时间】:2016-01-08 04:17:50
【问题描述】:
这里的逻辑错误是页脚的边距位置受while循环结果的影响。
这是问题的逻辑视图:https://www.dropbox.com/s/oxyt5o4pzmarome/before%20and%20after.png?dl=0
这是我的代码:
<div id="print_output1">
<?php
$con=mysql_connect("localhost","root","");
mysql_set_charset("UTF8", $con);
if(!$con)
{
die("Could not connect." .mysql_error());
}
mysql_select_db("dictionary_enhanced", $con);
if (isset($_POST['word']))
{
$search = $_POST['word'];
$search1=addslashes($search);
$query = "SELECT *" .
" FROM maranao, maranao_meaning, english, filipino, translate".
" WHERE maranao.mar_id = maranao_meaning.mar_id and maranao.mar_id = translate.mar_id and filipino.fil_id = translate.fil_id and english.eng_id = translate.eng_id and maranao.maranao_word like '$search1%' ORDER BY maranao.maranao_word ASC";
$result = mysql_query($query) or die(mysql_error());
$num_rows = mysql_num_rows($result);
if($num_rows==0)
{
echo "No Results Found. Please try again";
}
$previous_word = "";
$row = 0;
while($row = mysql_fetch_array($result))
{
// AM - Show the word only if it's a new one
if ($row["maranao_word"] != $previous_word)
{
echo "<div style='margin-bottom: 3px; color: white;'>.</div>";
// AM - close the previous word definition
if ($row == 0)
{
}
?>
<div style = "font-family:'Times New Roman'; font-size: 17px;">
Maranao word: <b><i><?php echo $row['maranao_word']; ?></i></b><br>
English word: <b><?php echo $row['english_word']; ?></b><br>
Filipino word: <b><?php echo $row['filipino_word']; ?></b><br>
Definition:
<?php
}
?>
<font color="white">:</font>
<div style="width:600px; border:0px solid orange; margin-left: 100px; word-wrap:break-word; margin-top: -17px;"><b><ul><li><?php echo $row['definition'] ?></li></ul></b></div>
<?php
// AM - Update the previous word and the row count
$previous_word = $row["maranao_word"];
$row++;
//echo "<br>";
}
// AM - close the last word definition
if ($row > 0)
{ echo "</div><br>"; }
}
mysql_close($con);
?>
</div><!-----end id="print_output1" ------>
</div><!-----end of id="container" ------>
</div><!-------end border shadow------->
<div id="footer"> <!---footer------>
footer <!---the footer here is affected when displaying all the results from the while loop above--->
</div>
</div> <!---------id="wrap"---->
【问题讨论】:
-
这是 CSS 问题,您能否通过搜索示例传递(最终)HTML 以及该 HTML 的 CSS?
-
不好说,但是看起来那是一个
<div>标签在搜索上没有关闭 -
这是您页面的完整代码吗?有 8 个打开的 div,只有 5 个关闭的。并且你需要在while循环中运行一个完整的div来维护布局
-
那不是完整的代码。我认为,在 while 循环内部是页脚受到影响的原因,我已经调试了大约 3 天,但仍然无法正常工作。