yes that is correct for placing the code.
where are you seeing the random order? Directly in the database, or on a php page that displays the products? If it is on a php page, then the recordset used to populate the page is not ordering by the ID column.