Jump to content

Recommended Posts

Hi there!

 

I've built a search that works but relies on the users to input their request very accurately.

 

The data they're searching on are phone numbers which come from a MySQL DB.

 

In the DB, phone numbers (from all over the world) are stored WITH spaces, like for example: 123 456 7890

 

What happens is people are typing in "1234567890" and this is coming up with no result.

This also occurs if users type in: "123 4567890"...

May be it would be also necessary to eliminate all spaces in the user's request prior to execute the query...

How should I write my queries to make them work?

 

Due to the infinite power of PHP, I'm quite sure a simple solution exists.

The script could first transform the user's string in a string with no spaces then compares this new string against those contained in the DB ignoring while reading the existing spaces...

This method avoid modification of the DB...

 

Any help would be most appreciated and I thank you in advance for it.

Link to comment
https://forums.phpfreaks.com/topic/66866-ignoring-spaces/
Share on other sites

Thank you very much for your appreciated reply!

 

Okay, understood, this is the first step: conversion of the user's string.

 

Now, how can I write my MySQL query to make it reading the field ignoring the spaces it contains?

Because if I don't do that, it will returns no result...

Link to comment
https://forums.phpfreaks.com/topic/66866-ignoring-spaces/#findComment-335182
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.