Question; When should I use $sql = "query etc"; and when should I use $result = mysqli_query($link, "query etc");? Are there other better ways to do it or worse ways to avoid? Thanks.
You use: $sql = "query etc"; PHP: when you want to do some extra operation with your $sql variable. Anyway you can use any of these without problem.
It really doesn't matter which one you use, as both do the same work. In first case you just assign query string to variable and then use mysqli_query to execute, while in the latter you just execute given string without any variable. In theory, second way should be more efficient.