case sensitivity in search
Moderator: General Moderators
case sensitivity in search
Dear all,
I want to search name in database and output, but I have to type name exactly (first letter is big) .
So how to solve if I want type all letters, which are small or big.
I want to search name in database and output, but I have to type name exactly (first letter is big) .
So how to solve if I want type all letters, which are small or big.
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Code: Select all
SELECT * FROM `table` WHERE `searchField` LIKE '$search'For your information:
AAA = big letters = uppercase
aaa = small letters = lowercase
Something that is case sensitive distinguishes between differing case.
Something that is case insensitive doesn't care what case the letters are.
@mods: help this guy out and rename the thread title methinks.
function to search, I have written
I have problem that it only is true follow example :
in database, table person , field name : Kevin
so if I search : Kevin --> it runs
but if I search : kevin --> nothing runs
but I want when I search Kevin or kevin, or KeVin, or KEVIN ==: it all runs
Thank in advice !!!
I have problem that it only is true follow example :
in database, table person , field name : Kevin
so if I search : Kevin --> it runs
but if I search : kevin --> nothing runs
but I want when I search Kevin or kevin, or KeVin, or KEVIN ==: it all runs
Thank in advice !!!
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Code: Select all
<form method = "POST" action = "edit_sDisplay.php">
<table border="0" width="100%" id="table1">
<tr>
<td width="8%"> </td>
<td width="10%"><b><font face="Arial" size="2">Name</font></b></td>
<td><input type="text" name= "name" size="30" style="font-family:Arial"> </td>
</tr>
<tr> <td> </td> </tr>
<tr>
<td width="50"> </td>
<td> </td>
<td><input type="submit" value=" Submit " name="submit">
</td>
<td> </td>
</tr>
</table>Code: Select all
$name = $_POST['name'];
db_connect();
$query = "SELECT name
FROM person
WHERE name = '$name'";
$result = mysql_query($query);id_person | name
1 | Kevin
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Nothing in your post suggests it's case sensitive.
will give you a table schema, post that please.
The only thing that scares me about your code is that it's open to SQL injection which you've been warned about previously.
Code: Select all
SHOW CREATE TABLE personThe only thing that scares me about your code is that it's open to SQL injection which you've been warned about previously.
oh, Thank you very much for your advice in last topic.thank thank
ah, do you want it
So I want to search last_name in table student
feyd | reformatted to readable form
ah, do you want it
Code: Select all
CREATE TABLE `student` (
`id_student` int(10) NOT NULL auto_increment,
`rc_student` varchar(6) collate latin2_czech_cs NOT NULL,
`last_name` varchar(15) collate latin2_czech_cs NOT NULL,
`first_name` varchar(15) collate latin2_czech_cs NOT NULL,
`street` varchar(15) collate latin2_czech_cs NOT NULL,
`city` varchar(15) collate latin2_czech_cs NOT NULL,
`country` varchar(15) collate latin2_czech_cs NOT NULL,
`number_telefone` varchar(12) collate latin2_czech_cs NOT NULL,
`faculty` varchar(15) collate latin2_czech_cs NOT NULL,
`year_school` varchar(1) collate latin2_czech_cs NOT NULL,
PRIMARY KEY (`id_student`),
KEY `rc_student` (`rc_student`,`last_name`,`first_name`)
) ENGINE=MyISAM AUTO_INCREMENT=29 DEFAULT CHARSET=latin2 COLLATE=latin2_czech_csfeyd | reformatted to readable form
I have formular for user type name . It is in page1.php
then I use command sql SELECT to search last_name
Code: Select all
<form method = "POST" action = "edit_sDisplay.php">
<table border="0" width="100%" id="table1">
<tr>
<td width="8%"> </td>
<td width="10%"><b><font face="Arial" size="2">Jméno</font></b></td>
<td><input type="text" name= "last_name" size="30" style="font-family:Arial"> </td></tr>
<tr><td width="50"> </td>
<td> </td>
<td><input type="submit" value=" Submit " name="submit"></td></tr>
</table>Code: Select all
$last_name = $_POST['last_name'];
db_connect();
$query = "SELECT last_name,first_name
FROM student
WHERE last_name = '$last_name'";
$result = mysql_query($query);