Using MySQL multi query and creating a counter variable in PHP

cntI had this problem where I need to change the order of the products we have and ¬†update them from the most popular to least popular. So what I did, I declared a variable that will act as a counter and set the column order_num to the current value of the counter. Here’s what I did:

You can also order specific record by adding an IN clause like: