简体   繁体   中英

echo a border bottom php

Is it possible to make a border at bottom using echo?

The reason i ask about this is that i cant find a good source that is directly an answer to my question. what i am trying to achieve here is to make a notification like that of facebook. This is because in my project i get the last 5 entry in database and i display it using echo so in order to distinguish the end of every entry i am thinking to make a border at bottom after every entry and suggestion is appreciated. This is how i display the data.

foreach (LoadEvent() as $value) {
    echo $value['searchresultwhat'];
    echo "<br/>\n";
    echo $value['searchresultwhen'];
    echo "<br/>\n";
    echo $value['searchresultwhere'];
    echo "<br/>\n";
    echo "<br/>\n";
}

you could try to add this line of code before the end of the foreach:

echo "<div style='border-bottom: 1px solid #000000'></div>";

It will be even better when you give the div a classname, and put the style-attribute in your CSS file.

The first solution is to use a <hr /> (which is a horizontal rule, looks like the line below this paragraph) instead of <br >


The above line is a <hr /> . You can use this in your code this way:

<?php
    foreach (LoadEvent() as $value)
    {
        echo $value['searchresultwhat'];
        echo "<hr/>\n";
        echo $value['searchresultwhen'];
        echo "<hr/>\n";
        echo $value['searchresultwhere'];
        echo "<hr/>\n";echo "<br/>\n";
    }
?>

But the preferred way is to use the CSS:

<?php
    foreach (LoadEvent() as $value)
    {
        echo "<div class='bb'>$value['searchresultwhat']</div>";
        echo "<div class='bb'>$value['searchresultwhen']</div>";
        echo "<div class='bb'>$value['searchresultwhere']</div>";
    }
?>

And give this in CSS:

.bb {border-bottom: 1px solid #ccc;}

You can stylize it using CSS3 selectors by this:

Let's say your results have class 'search-result' and it looks like this:

<div class="results">
   <div class="search-result">result 1 </div>
   <div class="search-result">result 2 </div>
   <div class="search-result">result 3 </div>
</div>

and into your CSS you should write this

.search-result:last-child {

border-bottom: 1px solid black; }

Do not use HR tag since it is deprecated and is very bad practice using it!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM