Forums

Making a xhtml valid searchform using a php if/else statement (3 posts)

  1. Paragamer09
    Member
    Posted 3 years ago #

    I'm trying to make a xhtml valid search form using an if/else php statement. I want the searchform to say 'Search...' before you type into it, but as soon as you type, it needs to show what you are typing.

    This is the code I have so far:

    value=" <?php
    if
      echo "Search";
    else
      echo "<?php the_search_query(); ?>";
    ?>

    I want the if statement to be something along the lines of if the search query is blank, however I have no idea how to write this in php.

    Any help will be greatly appreciated!

  2. chaoskaizer
    Member
    Posted 3 years ago #

    try

    ...
    value="<?php echo (( '' != get_search_query() ) ? get_search_query() : __('Search') ); ?>"
    ...
  3. warfman99
    Member
    Posted 2 years ago #

    There is a plugin that might do it for you. Not sure if this is exactly what you're going for, but I've used this plugin, and it works well and is very easy to setup.

    http://labs.jcow.com/plugins/enhanced-search-box/

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.