ArizonaJohn Posted May 21, 2009 Share Posted May 21, 2009 Hello, The HTML form and PHP below allow the user to lookup a table from a MySQL database with the table-name matching the variable "find." It works great, but I would like to make the user's input case-insensitive. If the user includes capital letters, I would like all of these to be converted into lower-case letters. How can I do this? Thanks in advance, John <form action="tsearch12.php" method="post"> <label>Enter Topic: <input type="text" name="find" size="55"/> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </label> </form> <? if ($searching =="yes") { if ($find == "") { echo "<p>You forgot to enter a search term"; exit; unset($_SESSION['find']); } mysql_connect("mysqlv3", "username", "password") or die(mysql_error()); mysql_select_db("sand2") or die(mysql_error()); $find = strip_tags($find); $find = trim ($find); $result=mysql_query("SHOW TABLES FROM sand2 LIKE '%$find%'") Link to comment https://forums.phpfreaks.com/topic/159130-solved-making-an-html-form-input-case-insensitive/ Share on other sites More sharing options...
Ken2k7 Posted May 21, 2009 Share Posted May 21, 2009 I thought it was case-insensitive to begin with but you can use SQL's COLLATE, LOWER() or PHP's strtolower Link to comment https://forums.phpfreaks.com/topic/159130-solved-making-an-html-form-input-case-insensitive/#findComment-839198 Share on other sites More sharing options...
Daniel0 Posted May 21, 2009 Share Posted May 21, 2009 I thought it was case-insensitive to begin with [...] You can have both case-sensitive and case-insensitive collations in MySQL. latin1_general_cs is case-sensitive for instance. Link to comment https://forums.phpfreaks.com/topic/159130-solved-making-an-html-form-input-case-insensitive/#findComment-839202 Share on other sites More sharing options...
ArizonaJohn Posted May 21, 2009 Author Share Posted May 21, 2009 Thanks, ken2k7, I just added $find = strtolower($find); to my code, and it works great. I appreciate the tip. -John Link to comment https://forums.phpfreaks.com/topic/159130-solved-making-an-html-form-input-case-insensitive/#findComment-839206 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.