Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9029953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:22:17+00:00 2026-06-16T07:22:17+00:00

Recently I’ve encountered an issue while attempting to create a search form and display

  • 0

Recently I’ve encountered an issue while attempting to create a search form and display the results in a list

    <?php 
        require_once ("Includes/simplecms-config.php"); 
        require_once  ("Includes/connectDB.php");
        include("Includes/header.php");         
     ?>

    <div id="main">
        <div id="searchcontent">
            <?php 
                $querysuccess = FALSE;
                $extsuccess = FALSE;
                if($_GET["query"] != "")
                {
                    echo '<h3>Results for "'.$_GET["query"].'"</h3>';
                    $querysuccess = TRUE;
                }

                if($_GET["ext"] != "*" && $_GET["ext"] != "")
                {
                    echo "<p>Matching extension: *.".$_GET["ext"]."</p>";
                    $extsuccess = TRUE;
                }
                else if($_GET["ext"] == "")
                {
                    echo "<p>No extension specified</p>";
                }
                else
                {
                    $extsuccess = TRUE;
                }

                if($querysuccess == TRUE && $extsuccess == TRUE)
                {
                    doSearch();
                }

                function doSearch()
                {
                    $query = $_GET["query"];
                    $extension = $_GET["ext"];

                    $sql_query = "SELECT * FROM search WHERE";
                    $querycount = 0;

                    $terms = explode(" ", $query);

                    foreach($terms as $word)
                    {
                        $querycount++;
                        if($querycount == 1) {
                            $sql_query .= " description LIKE '%$word%'";
                        }
                        else
                        {
                            $sql_query .= " OR description LIKE '%$word%'";
                        }
                    }

                    if($searchforextension == TRUE)
                    {
                        $sql_query .= "AND extension='$extension'";
                    }

                    mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
                    mysql_select_db(DB_NAME);

                    $sql_query = mysql_query($sql_query);
                    $numrows = mysql_num_rows($sql_query);
                    if($numrows > 0)
                    {
                        echo "<ul>";
                        while($proc_row = mysql_fetch_array($sql_query))
                        {
                            $script_id = $proc_row["id"];
                            $script_name = $proc_row["name"];
                            $script_description = $proc_row["description"];
                            $script_author = $proc_row["author"];
                            $script_authorURL = $proc_row["authorURL"];
                            $script_pathname = $proc_row["filename"];

                            $search_result = "<li><div class='result'>";
                            $search_result .= " <p class='result_title'>$script_name</p>";
                            $search_result .= " <p>$script_description</p>";
                            $search_result .= " <div class='result_footer'>";
                            $search_result .= "     <a href='$script_authorURL'"." class='result_author'>$script_author</a>";
                            $search_result .= "     <a href='/getscript.php?script=$script_id" . "&". "file=$script_pathname' class='result_download'>View</a>";
                            $search_result .= " </div>";
                            $search_result .= "</div></li><br /><br /><br />";
                            echo $search_result;

                        }
                        echo "</ul>";
                    }
                    else
                    {
                        echo "<br/><h2>Unable to find any results matching your query.</h2>";
                    }

                    mysql_close();
                }
            ?>
        </div>
    </div>

    </div>

    <?php 
        include ("Includes/footer.php");
     ?>

I am using Microsoft WebMatrix 2.0 to create this site based upon the PHP starter template, my issue is that when more than 1 object is displayed it overlaps the previous object and screws up the entire layout!

I can post parts of my CSS if required?

After following Wesley Murch’s advice I now have another issue

What's not working now http://img21.imageshack.us/img21/4498/screenshotgbf.png

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T07:22:18+00:00Added an answer on June 16, 2026 at 7:22 am

    You’re generating invalid HTML.

    Here, you close the <a> tag with </p> which is incorrect:

    $search_result .= "     <a href='/getscript.php?script=$script_id" . "&". "file=$script_pathname' class='result_download'>View</p>";
    

    Here you add <br> tags as a direct child of <ul> which is invalid:

    $search_result .= "</div></li><br /><br /><br />";
    

    The only valid direct child for a <ul> or <ol> is <li>.

    You also open 2 divs at the top of your HTML, but then you have 3 closing tags at the bottom.

    Invalid HTML is one of the leading causes of broken layouts. Use this tool in the future as your first stop for debugging HTML and/or CSS:

    http://validator.w3.org/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently I was able to create a tablet software for my Cerebral Palsy girl
Recently the PHP manual started showing the following warning on every mysql function page:
recently, while working on a db2 -> oracle migration project, we came across this
Recently, when I tried to show the results of my work (some Flex app)
Recently I worked in a project in where I need to display japanese text
Recently I faced a issue when using len() in a query to find out
Recently I installed a Visual Studio 2008 extension called VS.Php, made by Jcx Software:
Recently I started learning CoreData. Figured out how to create a database, create a
Recently I have encountered the concept of NoSQL and as far as I manage
Recently my iPad started to display these random characters when I open a website.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.