in general, there is almost always an sql solution which makes looping unnecessary, and this is true in this case as well
on Customers.Cust_ID = Products.Cust_ID
where Customers.Bill_Cycle_ID = '1'
and Products.Recurring = 'yes'
Also...in the first query when the cust_id is entered into the bills table the bill_id auto increments. I know I can use "last_insert_id" but it only grabs the first id not all of the id's if there's more than one. Is there a way to grab all id's just created in order to again insert into the item_billing_link table along with the product_id.