473,320 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Postgres search using php

250 100+
I'm developing web page with php and postgres. There I want to search database. This is my query:
Expand|Select|Wrap|Line Numbers
  1. $sql="SELECT * FROM \"User\" WHERE \"UserName\" LIKE '%$search%';";
  2.  
When I type "fernando" It gives all names including that name. But it didn't give names having "Fernando"(Capital letter).
Ex: Kez fenando, fernando,

not gives: Kenth Fernando
Jul 23 '09 #1
5 2864
bilibytes
128 100+
You have to insert consistent data in your database:

or all the names start with a captial leter,
or all the names are lowercased
or whatever way you like them to be.

then when you look for 'fernando' you will get all the records

if you want to case the name differently to show to your web users, then it should be done in the php side.

$name = ucords(strtolower($row['name']));

hope you understand
Jul 23 '09 #2
dlite922
1,584 Expert 1GB
Never used postgres: It's case sensitive?

You won't have this problem with MySQL.


Dan
Jul 23 '09 #3
Dormilich
8,658 Expert Mod 8TB
@dlite922
unless you use binary strings…
Jul 23 '09 #4
Canabeez
126 100+
@ghjk
Can't you use REGEX? Sorry, gave you the wrong link, that one goes to mySQL, here's what you need.
Jul 23 '09 #5
ghjk
250 100+
Thanx all. This is working
Expand|Select|Wrap|Line Numbers
  1. $sql="SELECT * FROM \"User\" WHERE \"UserName\"  ~*  '%$search%';";
  2.  
Jul 24 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jerry Asher | last post by:
I would like to map from GPS coordinates to US Zipcode for US Continental based needs. (Yes, I am excluding perhaps Hawaii and Alaska for now, and I am also assuming that a simple 2D geometry,...
3
by: N.K. | last post by:
Hi, I've just installed postgres on the Linux server. It is supposed to start automatically which I think it does since I can run an sql stmt right away. When I'm trying to connect from a remote...
7
by: Abdul-Wahid Paterson | last post by:
Hi, I have had a site working for the last 2 years and have had no problems until at the weekend I replace my database server with a newer one. The database migration went like a dream and I had...
4
by: Bernardo Robelo | last post by:
Hi, I am interested in migrating Microsoft Access database to Postgres database. But I do not have idea of like initiating. Maybe some tool exists for this problem. Thanks you. Bernardo
1
by: CSN | last post by:
Should "restart" with pg_ctl or /etc/init.d/postgres cause postgres.conf to be reread? It doesn't appear to do so for me (another oddity - after "restart" the last line in the log is "database...
7
by: Randy Yates | last post by:
This has probably been asked before so please be gracious. I have looked on the postgres site and didn't find anything "satisfying." Is there *good* overview of postgres and associated...
1
by: Liu, Mingyi | last post by:
Sorry if this question has been asked before. I tried to search in postgres mailing lists at http://archives.postgresql.org/pgsql-general/ just now and it gave me error "An error occured! Can not...
3
by: Fuzzydave | last post by:
I need to call a function stored in Postgres which does a lot of the db and calculation work all the SQL queries are hardcoded in a file called cmi.py. What i need to do is too to call my...
0
by: NM | last post by:
Hello, I've got a problem inserting binary objects into the postgres database. I have binary objects (e.g. images or smth else) of any size which I want to insert into the database. Funny is it...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.