如何在一个循环中正确显示所有英文定义而不在php中分离?

时间:2015-10-08 00:38:59

标签: javascript php sql

逻辑错误显示是具有更多含义的英语单词如下所示:

English word: lie (1)
Definition: not honest

English word: lie (1)
Definition: deliberately say something untrue

English word: lie (2)
Definition: to stretch out on a surface that is slanted or horizontal

English word: lie (2)
Definition: to be positioned on and supported by a horizontal surface

我希望输出显示如下:

English word: lie (1)
Definition: 1. not honest
            2. deliberately say something untrue

如果它具有不同含义的相同单词,则应该是输出:

English word: lie (1)
Definition: 1. not honest
            2. deliberately say something untrue

English word: lie (2)
Definition: 1. to stretch out on a surface that is slanted or horizontal
            2. to be positioned on and supported by a horizontal surface

这是我的代码:

    <?php                                   

    $search = $_POST['word'];

    $query = "SELECT *" .
             " FROM english, english_meaning, maranao, filipino, translate". 
             " WHERE english.eng_id = english_meaning.eng_id and english.eng_id = translate.eng_id and maranao.mar_id = translate.mar_id and filipino.fil_id = translate.fil_id and english.english_word like '$search%'";

            $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";
            }


                while($row=mysql_fetch_array($result))
                {
                ?>
                    <div style = " background-color: #daeaff; border-radius: 10px; padding: 15px;">
                    <font size='3' face='Times New Roman'>

                        English word: <b><?php echo $row['english_word']; ?></b><br>
                        Definition:<b><div style="width:600px; border:0px solid orange; margin-left: 79px; word-wrap:break-word; margin-top: -18px;"><?php echo $row['definition'] ?></b></div>

                    </font>
                    </div>
                    <?php echo "<br>"; ?>

                <?php
                }
            }
    mysql_close($con);
?>

0 个答案:

没有答案