php - How do I separate the while loop search results from the footer position? -
the logical error here footer's margin position affected while loop results.
here's logical view of problem: https://www.dropbox.com/s/oxyt5o4pzmarome/before%20and%20after.png?dl=0
here's code:
<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 *" . " maranao, maranao_meaning, english, filipino, translate". " maranao.mar_id = maranao_meaning.mar_id , maranao.mar_id = translate.mar_id , filipino.fil_id = translate.fil_id , english.eng_id = translate.eng_id , maranao.maranao_word '$search1%' order 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)) { // - show word if it's new 1 if ($row["maranao_word"] != $previous_word) { echo "<div style='margin-bottom: 3px; color: white;'>.</div>"; // - close 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 // - update previous word , row count $previous_word = $row["maranao_word"]; $row++; //echo "<br>"; } // - close 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 affected when displaying results while loop above---> </div> </div> <!---------id="wrap"---->
you have not closed div inside while loop. try below code
<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 *" . " maranao, maranao_meaning, english, filipino, translate" . " maranao.mar_id = maranao_meaning.mar_id , maranao.mar_id = translate.mar_id , filipino.fil_id = translate.fil_id , english.eng_id = translate.eng_id , maranao.maranao_word '$search1%' order 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)) { // - show word if it's new 1 if ($row["maranao_word"] != $previous_word) { echo "<div style='margin-bottom: 3px; color: white;'>.</div>"; // - close 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 // - update previous word , row count $previous_word = $row["maranao_word"]; $row++; echo "</div>"; //echo "<br>"; } // - close last word definition if ($row > 0) { echo "</div><br>"; } } mysql_close($con); ?> </div><!-----end id="print_output1" ------>
footer
Comments
Post a Comment