Click here to Skip to main content
15,445,242 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello, I'm trying to make an accordion for each row in the database using the Foreach loop
I tried this but I'm getting only one accordion:-

What I have tried:

                <?foreach ($fetchedDrafts as $draft):?>
                <div id="<?=$draft['name'];?>" role="tablist" class="border border-danger rounded" aria-multiselectable="true">

                    <div class="card">
                        <div class="card-header" role="tab" style="height:120px !important;" id="section1HeaderId">
                            <h5 class="mb-0">
                                <a data-toggle="collapse" data-parent="#accordianId" href="#section1ContentId" aria-expanded="true" aria-controls="section1ContentId">
                                <button type="button" class="btn btn-warning pill" style="display:none;"><?$draft['name'];?></button>
                                <h3 class="Title" style="display:none;font-family:hana;"></h3>
                                <img class="accordianimg pull-left" style="width:180px; height:120px;" src="..\upload\gsk.png" alt="alt"></img>

                        <div class="input-container" style="margin-top:2rem !important; margin-right:6rem;">
                        <button onclick="funvction()" class="btn btn-danger SearchButton"style="font-family:hana;">بحث</button>
                        <input class="border border-danger rounded SearchInput" type="text" style="width:440px;"id="SearchInput" placeholder="البحث عن المنتج" name="DraftSearchFiled" onchange="DraftSearch()">

                        <div id="section1ContentId" class="collapse in" role="tabpanel" aria-labelledby="section1HeaderId" style="overflow-x: hidden !important;" onscroll="">
                        <div class="card-body d-flex flex-wrap">
                        <div class="row justify-content-center">
                        <div id="demo" class="carousel slide carousel" data-ride="carousel" style="margin-left:20rem;width: 26rem; height:31rem;">
                        <!-- no need for indicators -->

                        <div class="carousel-inner canner">
                            $i = 0;
                            foreach($DRTitems  as $row){
                            $actives = '';
                            if($i == 0){
                            $actives ='active';
                        <div class="carousel-item  <?= $actives;?>">
                        <div class="container">
                        <div class="row justify-content-center">
                        <div class="card"  style="width: 26rem; height:auto;">
                        <? if($row['Sale'] == true){
                        echo'<div class="corner-ribbon top-left sticky shadow">تخفيض</div>';
                        echo'<div class="corner-ribbon top-left-green sticky shadow">افضل سعر</div>';
                        <img class="card-img-top" src="<?= $row['imageurl'] ?>" alt="Drug" style=""></img>
                        <div class="card-body body">
                            <h1 class="card-title Productname " style="font-family:Tahoma !important; font-size:42px !important;"><?= $row['name'] ?></h1><br><br><br>
                            <p class="chemicalcom"><?= $row['chemicalcom']?></p><br>
                            <p class="price"><?= $row['price'] ?>$</p>
                            <input type="submit" class="btn btn-success btn-sm btn-block btn" value="أضف للسلة"></input>
    <? $i++; }?>

  <?php endforeach; ?>
Member 15413331 31-Oct-21 9:19am    
You have a few spelling mistakes. Please check your code through and retry.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900