检查是否是指定数据的匹配记录库

I have this mysql syntax.

//select backup table and loop through all records until it find the row base from the id and then compare if the $itemname is match in itemname column or $itemdesc is match in itemdesc column
$sql2="SELECT * FROM backup WHERE id='$id' AND itemname='$itemname' OR itemdesc='$itemdesc'";
$result2 = mysqli_query($this->db,$sql2);
$user_data = mysqli_fetch_array($result2);
$count_row = $result2->num_rows;

if (!$count_row == 1) {
    //if theres no match either in the itemname or item desc..
    $error = $error + 1;
    echo "no match";
}

as you can see from the above, it will first select backup table and loop through all records inside on it until it find the row base from the id=$id and then compare if the $itemname is match in itemname column or $itemdesc is match in itemdesc column and then if there's no match either in itemname or itemdesc then generate and error but seems doesn't work, why???? any ideas, clues, suggestions, recommendations, help would be greatly appreciated, Thank you!

Remove the $user_data since it has no use around and change your sql syntax to

$sql2="
    SELECT * FROM backup
    WHERE id='$id'
    AND itemname='$itemname'
    AND itemdesc='$itemdesc'
";

since you want to compare either itemname or itemdesc.