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 8411837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:31:33+00:00 2026-06-10T00:31:33+00:00

I am working on an assignment right now where I am trying to build

  • 0

I am working on an assignment right now where I am trying to build a small real estate like website that builds a search from my mySQL database based on a user input city. I have it working right now to give back correct results based on if the user inputs the city exactly right, but I want it to be able to return searches if the user was to enter just part of the city.

An example is that some of the cities in the assignment are “Tomsville” and “OceanCove” I need to be able to have the search be able to return results for “Tomsville” if someone were to just input “Tom” or even “T”…the same needs to be true for “OceanCove” where they could input “ocean” and get the results.

The variable for the user input is $findhome.

Here is the part of my code relevant to this question:

 $statement  = "SELECT *";
 $statement .= "FROM u1585_homes ";

if ($findhome!= 'ALL')
{
    $statement .= "WHERE city ='".$findhome."' ";
}
    $statement .= "ORDER BY city";

    $sqlResults = selectResults($statement);

    $error_or_rows = $sqlResults[0];

    if (substr($error_or_rows, 0 , 5) == 'ERROR')
    {
        print "<br />Error on DB";
        print $error_or_rows;
        } else {

                $arraySize = $error_or_rows;

                for ($i=1; $i <= $error_or_rows; $i++)
                {
                    $image_file = $sqlResults[$i]['image_file'];
                    $city = $sqlResults[$i]['city'];
                    $price = $sqlResults[$i]['price'];
                    $bedrooms= $sqlResults[$i]['bedrooms'];
                    $baths= $sqlResults[$i]['baths'];
                    $footage = $sqlResults[$i]['footage'];
                    $realtor_firstname = $sqlResults[$i]['realtor_firstname'];
                    $realtor_lastname = $sqlResults[$i]['realtor_lastname'];
                    $grabber = $sqlResults[$i]['grabber'];
                    $description = $sqlResults[$i]['description'];

                    print "<p><img src='images/".$image_file."'>";
                    print "<h3>".$grabber."</h3><br />";
                    print "City: ".$city."<br />";
                    print "Bedrooms: ".$bedrooms."<br />";
                    print "Baths: ".$baths."<br />";
                    print "Price: ".$price."<br />";
                    print "Footage: ".$footage."<br />";
                    print "Realtor: $realtor_firstname ".$realtor_lastname."<br />";

                    print "Description: ".$description;
                    //print ""
                }               
        }
    }
  • 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-10T00:31:35+00:00Added an answer on June 10, 2026 at 12:31 am

    Try using % around the search terms and using like instead of = as the operator:

    $statement .= "WHERE city like '%".$findhome."%' ";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an assignment that deals with reading data from a text
I've been working on a comprehensive build system that performs distributed builds on multiple
I'm working on my assignment of PHP course. The problem that I don't understand
I am working on an assignment that is giving me grief. I am supposed
I am working on a short java assignment that I have been set. The
Right now, I am working on a web project in PHP and for the
I'm currently working on a program (for fun, this is not an assignment) that
I've been working on an assignment and now I'm stuck with buggy destructors. I
I am working on assignment for school. It manly consists of a method that
I'm working on an assignment that is telling me to assume that I have

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.