How to display php rows with the same value as in HTML?
P粉460377540
P粉460377540 2024-03-20 08:47:28
0
1
442

Get multiple data with the same value from the database. How can I structure it so it will work as a subcategory. How to merge all rows with the same name into one?

The website should display only one Pampanga. This should be a subcategory.

This is the code for this particular page.

<section class="page-section bg-dark" id="home">
    <div class="container">
        <h2 class="text-center">Tour Packages</h2>
    <div class="d-flex w-100 justify-content-center">
        <hr class="border-warning" style="border:3px solid" width="15%">
    </div>
    <div class="d-flex w-100">
        <?php
        $packages = $conn->query("SELECT * FROM `packages` order by rand() ");
            while($row = $packages->fetch_assoc() ):
                $cover='';
                if(is_dir(base_app.'uploads/package_'.$row['id'])){
                    $img = scandir(base_app.'uploads/package_'.$row['id']);
                    $k = array_search('.',$img);
                    if($k !== false)
                        unset($img[$k]);
                    $k = array_search('..',$img);
                    if($k !== false)
                        unset($img[$k]);
                    $cover = isset($img[2]) ? 'uploads/package_'.$row['id'].'/'.$img[2] : "";
                }
                $row['description'] = strip_tags(stripslashes(html_entity_decode($row['description'])));
        ?>
            <div class="card w-100 rounded-0">
                <img class="card-img-top" src="<?php echo validate_image($cover) ?>" alt="<?php echo $row['title'] ?>" height= "200rem" style="object-fit:cover">
                <div class="card-body">
                <h5 class="card-title truncate-1"><?php echo $row['title'] ?></h5>
                <p class="card-text truncate"><?php echo $row['description'] ?></p>
                <div class="w-100 d-flex justify-content-end">
                    <a href="./?page=packages&id=<?php echo md5($row['id']) ?>" class="btn btn-sm btn-flat btn-warning">View Package <i class="fa fa-arrow-right"></i></a>
                </div>
                </div>
            </div>
        <?php endwhile; ?>
    </div>
    <div class="d-flex w-100 justify-content-end">
        <a href="./?page=packages" class="btn btn-flat btn-warning mr-4">Explore Package <i class="fa fa-arrow-right"></i> ;</a>
    </div>
    </div>
</section>

P粉460377540
P粉460377540

reply all(1)
P粉462328904

If you only need one instance of each tour location you drive to, use a group by statement in your request.

SELECT tour_location FROM `your_table_name` GROUP BY tour_location;

View more informationhttps://sql.sh/cours/group-by

Another solution might be to use sql DISTINCT.

SELECT DISTINCT tour_location FROM `your_table_name`
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template