LanceT Posted January 13, 2007 Share Posted January 13, 2007 I'm using the following code[code] $result = mysql_query("SELECT * FROM `table` WHERE type='$type' ORDER BY `name` ASC LIMIT 0,5", $dbh);[/code]I have a row of types in my Mysql database, but is there a way I can make it so that type doesn't have to exactly equal the type in my database, but it only requires that the $type be present somewhere inside the string?To be more clear, if $type was "hello", then it would select types of "hello" but also "hello, world" Link to comment https://forums.phpfreaks.com/topic/33988-selecting-from-a-mysql-table/ Share on other sites More sharing options...
trq Posted January 13, 2007 Share Posted January 13, 2007 [code=php:0]$result = mysql_query("SELECT * FROM `table` WHERE type LIKE '%$type%' ORDER BY `name` ASC LIMIT 0,5", $dbh);[/code] Link to comment https://forums.phpfreaks.com/topic/33988-selecting-from-a-mysql-table/#findComment-159717 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.