<?php
require 'require/conn.php';

if (isset($_POST['network'])) {
    $network = $_POST['network'];
    $query = "SELECT dataplan_id, data_name FROM data_plans WHERE network = ? AND data_status = 'On'";
    $stmt = $conn->prepare($query);
    $stmt->bind_param("s", $network);
    $stmt->execute();
    $result = $stmt->get_result();

    $options = '<option value="">-- Select Data Plan --</option>';
    while ($row = $result->fetch_assoc()) {
        $options .= '<option value="' . htmlspecialchars($row['dataplan_id']) . '">' . htmlspecialchars($row['data_name']) . '</option>';
    }
    echo $options;
}
?>