How to style a PHP generated label?


Tags: php,html,css

Problem :

I have this IF clause snippet from a PHP script that is basically a small search engine:

if(isset($_REQUEST['search'])){
    $search_term = trim($_REQUEST['search']);
    if(strlen($search_term) <= 0){
        $website_search_dynamic -> error($website_search_dynamic->label("Please enter a search query."),true);
    }else if(strlen($search_term) < $GLOBALS['_SEARCH_MIN_CHARS']){
        $website_search_dynamic -> error($website_search_dynamic->label("Sorry, you must enter at least %d characters in your search query",$GLOBALS['_SEARCH_MIN_CHARS']),true);
    }
    $website_search_dynamic -> search($search_term);
}

How do I add CSS styling to the two labels? For example, I would like either error message to be displayed in a centered div. Nothing too fancy.

Thanks!



Solution :

You could just do:

if(strlen($search_term) <= 0){
$error[] = "Nope";
}

And then wherever you want in your html, put:

<?php   
if(!empty($error))  {
   echo "<div align='center' class='foo'>" . $error [0] . "</div>"; 
   }
   ?>

And style the class however you want.


    CSS Howto..

    How to change ol bullets for clickable images

    CSS How to set div height 100% minus nPx

    How can I force browsers to reload cached CSS files when using Asp.Net Themes? [duplicate]

    How to make a paragraph appear in a certain area in the page using Wordpress?

    How to stop jquery from overriding CSS color?

    How to make content inside a circle div fitting correctly

    How to calculate the multiplication factor for scroll speed on another element so that they both reach end at the same time (top of view)

    How to print HTML/PHP page without including the NAVIGATION TAB contents, FOOTER, and head part

    How to locate the element within CSS using javascript

    How to make an html section right justified and shift to a new row if the window is narrow?

    How to change CSS style of div after onclick method

    How to Apply css class on runTime

    How to position a set in Raphael SVG?

    Navbar doesn't scroll to show links on smaller devices when using nicescroll plug-in

    How to change a lot of img when hover

    How to change the background color of a span/div WITHOUT CSS [closed]

    How to style an add to cart

    How to make the div at the screen center not lower right corner?

    how to relocation dropdownmenu by CSS

    How to display form labels with more than one element per line? jsfiddle

    How can I center a box in CSS?

    How to gracefully override the old css with a new css by jQuery?

    How to attach CSS to my template?

    how to make nav brand centrally aligned

    How to hide a
    item with CSS?

    How to make a webpage mobile friendly with css media queries

    How to preload large css and javascript files in vanilla javascript

    How to horizontally stack elements using CSS?

    How to update a div with another image in angular?

    How to use Open Sans font with cakePhp 3?