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 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 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 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? 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. 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
Archived
This topic is now archived and is closed to further replies.