hasanatkazmi Posted January 29, 2008 Share Posted January 29, 2008 I am new to MySql, how can i search for a value in specific column in the table suppose table is $table, and coulmn is $cloumn and I am searching for a some variable say $var Quote Link to comment https://forums.phpfreaks.com/topic/88458-solved-how-to-search-a-table/ Share on other sites More sharing options...
craygo Posted January 29, 2008 Share Posted January 29, 2008 $sql = "SELECT * FROM `$table` WHERE `$column` = '$var'"; this will work as long as there is nothing but that value in the column. If there is more text you will get back nothing. You would have to use LIKE and wildcards to get more results $sql = "SELECT * FROM `$table` WHERE `$column` LIKE '%".$var."%'"; Ray Quote Link to comment https://forums.phpfreaks.com/topic/88458-solved-how-to-search-a-table/#findComment-452751 Share on other sites More sharing options...
naveenbj Posted January 29, 2008 Share Posted January 29, 2008 Hello select*from $table where $cloumn=$var; I thinkit should work Regards Nj Quote Link to comment https://forums.phpfreaks.com/topic/88458-solved-how-to-search-a-table/#findComment-452755 Share on other sites More sharing options...
hasanatkazmi Posted January 29, 2008 Author Share Posted January 29, 2008 mysql_query on sql fetches an array??? is it so? Quote Link to comment https://forums.phpfreaks.com/topic/88458-solved-how-to-search-a-table/#findComment-452760 Share on other sites More sharing options...
revraz Posted January 29, 2008 Share Posted January 29, 2008 mysql_fetch_array fetches an array mysql_query performs the query. Quote Link to comment https://forums.phpfreaks.com/topic/88458-solved-how-to-search-a-table/#findComment-452762 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.