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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:00:45+00:00 2026-05-15T20:00:45+00:00

I am using MySQL and the ‘like’ query in order to find pages. I

  • 0

I am using MySQL and the ‘like’ query in order to find pages. I need to be able to do things this way, but this means that these pages will be the same:

http://www.mysite.com/blog/hello-world

http://www.mysite.com/blog/hello-worl

They both work, and bring up the same page. How (possibly using .htaccess?) can I get around this problem? :\

Many thanks

EDIT:

PHP –

if(isset($_GET['title'])) {
                $blogtitle=mysql_real_escape_string($_GET['title']);
                $title_two = strtolower(str_replace("-", " ", $blogtitle));
                $title_two = strtolower(str_replace("?", "", $title_two));
                $title_two = mysql_real_escape_string($title_two);

                $postmatch = "select * from blog where title LIKE '%".$title_two."%' LIMIT 1;";
                $postquery = mysql_query($postmatch) or die ("Could not match data because ".mysql_error());
                $blogtitle=mysql_result($postquery,0,"title");

                $title="$blogtitle";
  • 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-05-15T20:00:46+00:00Added an answer on May 15, 2026 at 8:00 pm

    Well you have the the URL : http://www.mysite.com/blog/hello-world WHERE hello world is the search string

    I recommended you to store them into array like

    $keyWrd = array();
    $keyWrd = strtolower($_GET['keywd']); // MUST DO VALIDATION
    $keyWrd = explode(" ",$keyWrd);
    $TotalKeyVal = count($keyWrd);
    
    if(!empty($keyWrd[0]))
        {
            $SrcQryStr = "SELECT id,title,body FROM tbl_name WHERE";
            for($i=0;$i<$TotalKeyVal;$i++)
                {
                    $SrcQryStr .= " title LIKE '%";
                    $SrcQryStr .= $keyWrd[$i];
                    $SrcQryStr .= "%'";
    
                    $SrcQryStr .= ' OR ';
    
                    $SrcQryStr .= " body LIKE '%";
                    $SrcQryStr .= $keyWrd[$i];
                    $SrcQryStr .= "%'";
    
                    if(($TotalKeyVal-1)!=$i) $SrcQryStr .= ' OR ';
                }
            $SrcQryStr .= " ORDER by created_date DESC";
    

    Now you have the $SrcQryStr Query string You can make more condition on if(!empty($keyWrd[0]) && MORE HERE) In here you can use implode or multiple implode instead of for loop.

    Now why %.$keywd.%

    Example :

    STRING : Welcome to Stack Overflow!

    Searched Keyword : ack

    it will show match found because ack found on Stack WHILE %.$keywd.%

    it will not show match found because there is no word which starts with ack WHILE $keywd.%

    it will not show match found because there is no exact word ack WHILE $keywd

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

Sidebar

Related Questions

MySQL Query works fine using MySQL workbench but produces an error when I am
(Using MySQL 4.1.22) I can't get this query of mine to use an index
Using MySQL 5 I have a table like this: date (varchar) door (varchar) shift
Using MySQL, i have a current timestamp that looks like this: 2011-11-01 10:34:24 Is
Im using mysql with PHP, I was just wondering if this query, $query =
Using MySQL with a very large table (millions of entries), I need to find
Using mysql and PHP, I'd like to setup a query which pulls a problem
I'm using MySQL. I have a table where I need to be able to
Currently using MySQL version 5.1.6 This is my first real world build and so
Using mysql 5.1.41 and innodb I'm doing some data import, but can't use load

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.