Created the generateCode function that creates the MySQL query based on the form inputs. Works with all active links, order and number of links but not categories.