What about doing it something like:
$trend='5,6,7';
$variableAry=explode(",",$trend);
foreach($variableAry as $var)
{
$sql="insert into trending_lawyer(id,lawyers_id)values('','$var')";
$query=mysql_query($sql);
}
There are other ways to optimize you code, but, for starters, this should work for you.
Just realized that you are trying to insert id as part of insert statement, if id is a PR and AI column, you can skip it in you insert statement, so, you code will look like:
$trend='5,6,7';
$variableAry=explode(",",$trend);
foreach($variableAry as $var)
{
$sql="insert into trending_lawyer(lawyers_id)values('$var')";
$query=mysql_query($sql);
}