| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #2 (permalink) |
| Pro Coder & Designer Join Date: Apr 2005 Location: Netherlands
Posts: 967
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | $sql = "SELECT * FROM table WHERE letter='$l'"; and then it would be page.php?l=e
__________________ aween web development |
| |
| | #4 (permalink) |
| DNOA Member Join Date: May 2004
Posts: 5,040
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | SELECT * FROM tablename WHERE field LIKE '%e%' LIMIT 10 Alternatively... to use a variable... $query = mysql_query("SELECT * FROM tablename WHERE field LIKE '%".$variable."%' LIMIT 10"); You can take out the LIMIT 10 if you want. |
| |
| | #5 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,074
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | compuXP's response is exactly what you are after. Just a note the % wildcard matches any amount of letters including 0 there is also a wildcard which is _ this matches any single character if you wanted say for example any result that contained e but did not start with e you could combine the 2 and have SELECT * FROM tablename WHERE field LIKE '_%e%' LIMIT 10 |
| |
| | THREAD STARTER #6 (permalink) |
| Senior Member Join Date: Aug 2005 Location: East Yorkshire, England
Posts: 2,689
![]() ![]() ![]() ![]() ![]() ![]() ![]() | how would i only return firlds that did not contain that value? eg return field 1, 2 and 3 if they all contain the criteria and then return all the rows where field1 is not the criteria field2 is and field 3 is |
| |
| | #7 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,074
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | if you want to find something that does not fit the criteria instead of using LIKE in the query you would use NOT LIKE Not sure if this fully answers your question as I did not fully understand what you wanted. |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| HOWTO: Install the Apache Web Server, Perl, PHP, and MySQL on Windows | deadserious | Webmaster Tutorials | 96 | 05-27-2007 01:24 PM |
| Tutorial: How to Install Apache2 MySQL and PHP on Windows | deadserious | Webmaster Tutorials | 35 | 09-21-2005 09:46 PM |
| HOW TO: Use shell to control MySQL. | abdulmueid | Webmaster Tutorials | 16 | 08-27-2005 08:17 AM |
| 800MB Space, 25GB Bandwidth, Unl. MySQL DB, and more Just $4.00 a month! | resellerlogic | Web Hosting Offers | 0 | 04-05-2005 06:44 PM |
| Tutorial: Getting Started With MySQL (The Basics) | deadserious | Webmaster Tutorials | 3 | 04-18-2004 01:17 PM |