在表中搜索字段/列以查找字符串

I want to search a column in a MySQL table for a string that is defined by a variable. How would that syntax look to do this?

How I imagine it in my head:

$var = 'this is a string';

$query = 'SEARCH column IN table for ' . $var;

If it is found a number will be appended to the string using PHP and $var will become:

$var = 'this is a string2';

How is this done? Thanks

$str = "this is a string";

$getstringexists = mysql_query("SELECT * FROM table WHERE column LIKE '$str'", $connection);
$string_exists = mysql_num_rows($getstringexists);

if($string_exists){
   $str .= "$sting_exists";
}

Connect to your database in your own way, I always use a variable like $connection at the end of my query that contains my db info.

If the query returns 5 rows it should make the new $str equal to "this is a string5";