How to loop through a list of database records in html/python

I have a list of records from a database associated with a production order in the following format:

7|P50001929|2024-05-06|23|15|15|0|6-7|000184351|123.0|testing a test remark
8|P50001929|2024-05-06|12345|90|90|0|10-12|000184351|43.0|please work
9|P50001929|2024-05-06|19|234|89084|809|089|000184351|0.0|88

I am passing this to a file called results.html that I want to print each record as a row on the page.
Below is the function that calls a display_results() function which renders results.html:

@app.route('/save_production_data', methods=['POST'])
@login_required
def save_production_data():

    print("NOW INSIDE SAVE PRODUCTION DATA FUNCTION")
    query_results_str = session.get('query_results', '[]')  # Default to empty list if not found
    query_results = json.loads(query_results_str)
    pdno = query_results[0].get("pdno")
    
    # Get data from the POST request
    date_str = request.form.get("date")
    print("Date string entered:", date_str)
    clock_number = request.form.get("clock_number")
    print("Clock number entered:", clock_number)
    total = int(request.form.get("total", 0))
    print("Total entered:", total)
    acceptable = int(request.form.get("acceptable", 0))
    print("Acceptable entered:", acceptable)
    scrap = int(request.form.get("scrap", 0))
    print("Scrap entered:", scrap)
    box_reel = request.form.get("box_reel")
    print("Box reel entered:", box_reel)
    lot_number = request.form.get("lot_number")
    print("Lot number entered:", lot_number)
    weight = float(request.form.get("weight", 0))
    print("Weight entered:", weight)
    remarks = request.form.get("remarks")
    print("Remarks entered:", remarks)

    # Convert the date string to a Python date object
    date = datetime.strptime(date_str, "%Y-%m-%d").date()

    # Create a new entry regardless of existing data
    new_entry = ProductionData(
        pdno=pdno,
        date=date,
        clock_number=clock_number,
        total=total,
        acceptable=acceptable,
        scrap=scrap,
        box_reel=box_reel,
        lot_number=lot_number,
        weight=weight,
        remarks=remarks,
    )
    
    # Add the new entry to the database
    db.session.add(new_entry)
    db.session.commit()

    print("Production data saved successfully!", "success")
    print("Pdno being passed to get_production_data: ", pdno)
    print("All production order data currently: ", get_production_data(pdno))
    for production_data in get_production_data(pdno):
            print("Production Data:")
            print("  Date:", production_data.date)
            print("  Clock Number:", production_data.clock_number)
            print("  Total:", production_data.total)
            print("  Acceptable:", production_data.acceptable)
            print("  Scrap:", production_data.scrap)
            print("  Box/Reel:", production_data.box_reel)
            print("  Lot Number:", production_data.lot_number)
            print("  Weight:", production_data.weight)
            print("  Remarks:", production_data.remarks)
    #print("Production data type:", type(production_data))
    # Redirect or return with updated data
    return display_results(query_results, get_production_data(pdno))

The above code prints the following:

Production Data:
  Date: 2024-05-06
  Clock Number: 23
  Total: 15
  Acceptable: 15
  Scrap: 0
  Box/Reel: 6-7
  Lot Number: 000184351
  Weight: 123.0
  Remarks: testing a test remark
Production Data:
  Date: 2024-05-06
  Clock Number: 12345
  Total: 90
  Acceptable: 90
  Scrap: 0
  Box/Reel: 10-12
  Lot Number: 000184351
  Weight: 43.0
  Remarks: please work
Production Data:
  Date: 2024-05-06
  Clock Number: 19
  Total: 234
  Acceptable: 89084
  Scrap: 809
  Box/Reel: 089
  Lot Number: 000184351
  Weight: 0.0
  Remarks: 88

Here is the display_results() function that renders the html page:

def display_results(query_results, production_data=None):
    """
    Display results page with given query results and production data.
    """
    print("Display results just called")
    print("Passed variable query_results:", query_results)
    if production_data:
        print("Production data type:", type(production_data))
        print("Production data provided:", production_data)
        for production_data in production_data:
            print("Production Data:")
            print("  Date:", production_data.date)
            print("  Clock Number:", production_data.clock_number)
            print("  Total:", production_data.total)
            print("  Acceptable:", production_data.acceptable)
            print("  Scrap:", production_data.scrap)
            print("  Box/Reel:", production_data.box_reel)
            print("  Lot Number:", production_data.lot_number)
            print("  Weight:", production_data.weight)
            print("  Remarks:", production_data.remarks)
    else:
        print("No production data provided")

    if not isinstance(production_data, list):
        print("Production data is not a list, converting to list")
        production_data = [production_data]

    # Render the results template with both query_results and production_data
    return render_template(
        'results.html',
        query_results=query_results,
        production_data=production_data,
    )

I am verifying that it is printing everything as expected.
Here is the problem area in results.html:

<!-- Table to display existing production data -->
    <h2>Previous Entries</h2>
    <table>
        <thead>
            <tr>
                <th>Date</th>
                <th>Clock #</th>
                <th>Total</th>
                <th>Acceptable</th>
                <th>Scrap</th>
                <th>Balance</th>
                <th>Box/Reel</th>
                <th>Lot Number</th>
                <th>Weight</th>
                <th>Remarks</th>
            </tr>
        </thead>
        {% if production_data and production_data|length > 0 %}
            {% for data in production_data %}
                <tr>
                    <td>{{ data.date }}</td>  <!-- Date -->
                    <td>{{ data.clock_number }}</td>  <!-- Clock # -->
                    <td>{{ data.total }}</td>  <!-- Total -->
                    <td>{{ data.acceptable }}</td>  <!-- Acceptable -->
                    <td>{{ data.scrap }}</td>  <!-- Scrap -->
                    <td>{{ (data.total or 0) - (data.acceptable or 0) }}</td>  <!-- Balance -->
                    <td>{{ data.box_reel }}</td>  <!-- Box/Reel -->
                    <td>{{ data.lot_number }}</td>  <!-- Lot Number -->
                    <td>{{ data.weight }}</td>  <!-- Weight -->
                    <td>{{ data.remarks }}</td>  <!-- Remarks -->
                </tr>
            {% endfor %}
        {% else %}
            <tr>
                <td colspan="11">No previous data found for this production order.</td>
            </tr>
        {% endif %}
    </table>
</body>

For some reason, this html section is only printing the last record added to the database. I want it to be printing each one in a row format. Am I missing something here that may be causing this?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật