<?php require ("top.php");  
$query="SELECT * FROM tbl_categroies"; 
$res=mysqli_query($con,$query); 
?>

<!-- Content Wrapper -->
<div class="content-wrapper" style="background: linear-gradient(135deg, #f5f7fa, #c3cfe2); padding: 20px;">
    
    <!-- Page Header -->
    <section class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-8 mx-auto">
                    <div class="card shadow-lg border-0 rounded-lg">
                        <div class="card-header bg-primary text-white">
                            <h3 class="card-title">📰 News Form</h3>
                        </div>
                        <!-- Form Start -->
                        <form action="catcode.php" method="post" enctype="multipart/form-data">
                            <div class="card-body">
                                <div class="form-group">
                                    <label for="categroies">🔗 Link</label>
                                    <input type="text" class="form-control" id="categroies_name" name="categroies_name" placeholder="Enter Link Name" required>
                                </div>
                                <div class="form-group">
                                    <label for="subject">📌 Subject</label>
                                    <textarea id="message" name="message" class="form-control" placeholder="Write something..."></textarea>
                                </div>
                                <div class="form-group">
                                    <label for="photo">🖼 Upload Photo</label>
                                    <input type="file" class="form-control-file" id="file" name="pic">
                                </div>
                            </div>
                            <!-- Submit Button -->
                            <div class="card-footer text-center">
                                <button type="submit" class="btn btn-success px-4 py-2">Submit</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Data Table -->
    <section class="content">
        <div class="container-fluid">
            <div class="row">
                <div class="col-12">
                    <div class="card shadow-lg border-0 rounded-lg">
                        <div class="card-header bg-dark text-white">
                            <h3 class="card-title">📊 News Data Table</h3>
                        </div>
                        <div class="card-body">
                            <table id="example1" class="table table-hover table-striped table-bordered">
                                <thead class="bg-secondary text-white">
                                    <tr>
                                        <th>S.N</th>
                                        <th>🔗 Link Name</th>
                                        <th>✏ Edit</th>
                                        <th>❌ Delete</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php 
                                    $a=1;
                                    while($row=mysqli_fetch_array($res)) { ?>
                                    <tr>
                                        <td><?php echo $a; ?></td>
                                        <td><?php echo $row['categroies_name']; ?></td>
                                        <td class="text-center">
                                            <a href="editcat.php?id=<?php echo $row['cid']; ?>" class="btn btn-warning btn-sm">✏ Edit</a>
                                        </td>
                                        <td class="text-center">
                                            <a href="deletecat.php?id=<?php echo $row['cid']; ?>" class="btn btn-danger btn-sm">🗑 Delete</a>
                                        </td>
                                    </tr>
                                    <?php $a++; } ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
