1) Good job using mysql_real_escape_string
2) You can use $name, but it would be like this $name = str_replace(' ', '-', $query_row['name']);
3) You can't simply re-search something like 'corner-tv-units' because you have changed the string, you would need to undo it. Something like str_replace('-',' ', $name);
4) If you are absolutely sure you can revert a string replace go ahead with it, otherwise a better solution is to have an extra field that holds the rewritten value, so your query would change from name LIKE '.....' to url_name = '$name'