frist44 Posted March 6, 2009 Share Posted March 6, 2009 I have a simple table displaying fields and filtering by date and status. I would like to have a search field that modifies the SQL query. How is that usually handled when the textbox is empty? I have it set when: extract($_POST, EXTR_SKIP); if (!$_POST){ $txtsearch = "%"; } But when there is the txtsearch field is empty is returns nothing. ideas? Link to comment https://forums.phpfreaks.com/topic/148293-search-field-in-a-table-with-mysql-db/ Share on other sites More sharing options...
redarrow Posted March 6, 2009 Share Posted March 6, 2009 some think like this you mean i think. <?php $sql="SELECT * FROM what_ever WHERE search_field LIKE '%$form_name_of_search_field%'"; $sql=mysql_query($sql)or die(mysql_error()); ?> Link to comment https://forums.phpfreaks.com/topic/148293-search-field-in-a-table-with-mysql-db/#findComment-778506 Share on other sites More sharing options...
frist44 Posted March 6, 2009 Author Share Posted March 6, 2009 Yeah that was it. I forgot to surround it with %. Thanks. Link to comment https://forums.phpfreaks.com/topic/148293-search-field-in-a-table-with-mysql-db/#findComment-778512 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.