Jump to content

pospan

New Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by pospan

  1. Hello I am working on a comment system in my custom cms i want to implement a Reply to an existing comment feature. My basic structure looks now like this. Users can only add comments with no Tree. All comments are going bellow another comment. I want only one 1 lvl after the main comment. Do I miss a field in DB, i don't get the right logic? What Am I missing in the markup?

     

    Table: komentari

    komentarID
    komentar_clanak_ID
    komentar_dodao
    komentar_email
    komentar_sadrzaj
    komentar_status
    komentar_datum
    <!--- Komentari --->
    
    
    <?php
    if(isset($_POST['dodaj_komentar'])){
    $clanak_id = $_GET['ID'];
    $komentar_dodao = $_POST['komentar_dodao'];
    $komentar_email = $_POST['komentar_email'];
    $komentar_sadrzaj = $_POST['komentar_sadrzaj'];
    if(!empty($komentar_dodao) && !empty($komentar_email) && !empty($komentar_sadrzaj)){
    $upit = "INSERT INTO komentari (komentar_clanak_ID, komentar_dodao, komentar_email, komentar_sadrzaj, komentar_status, komentar_datum)";
    
    
    $upit .= "VALUES ($clanak_id, '{$komentar_dodao}', '{$komentar_email}', '{$komentar_sadrzaj}', 'Na čekanju', now())";
    $dodaj_komentar_upit = mysqli_query($konekcija, $upit);
    if(!$dodaj_komentar_upit){
    mysqliGreska($dodaj_komentar_upit);
    }
    
    
    $upit = "UPDATE novost SET brojacKomentara = brojacKomentara + 1 ";
    $upit .= "WHERE novostID = $clanak_id ";
    $brojacKomentara_upit = mysqli_query($konekcija, $upit);
    mysqliGreska($brojacKomentara_upit);
    }  
    
    
    
    
    else {
    echo "<script>alert('Prilikom unosa komentara ostavili ste neko od polja prazno. Molimo, ispravite to te pokušajte ponovo unijet komentar.')</script>";
    }
    }
    ?>
    
    
    <div id="komentarOkvir">
    <form class="formaIzgled" action="" method="POST" autocomplete="off">       
    <label for="komentar_dodao">Korisničko ime</label>
    <input name="komentar_dodao" type="text" placeholder="Unesite vaše ime">
                
    <label for="komentar_email">Email</label>
    <input name="komentar_email" type="text" placeholder="Unesite vaš email">
                
    <label for="komentar_sadrzaj">Sadržaj</label>
    <textarea name="komentar_sadrzaj" placeholder="Sadržaj komentara"></textarea>
                
    <input name="dodaj_komentar" type="submit" value="Dodaj komentar!">
    </form>
    
    
    
    
    <?php
    $upit = "SELECT * FROM komentari WHERE komentar_clanak_ID = {$clanak_id} ";
    $upit .= "AND komentar_status = 'prihvaćen' ";
    $upit .= "ORDER BY komentarID DESC";
    $odaberi_komentare_upit = mysqli_query($konekcija, $upit);
    if(!$odaberi_komentare_upit){
    mysqliGreska($odaberi_komentare_upit);
    }
    while ($red = mysqli_fetch_array($odaberi_komentare_upit)){
    $komentar_datum = $red['komentar_datum'];
    $komentar_sadrzaj = $red['komentar_sadrzaj'];
    $komentar_dodao = $red['komentar_dodao'];
    
    
    ?>
    
    
    <div class="komentarOdgovorOkvir">
    <div class="komentarOdgovorSlika"><img src="slike/01.jpg" alt="Mountain View"></div>
    <div class="komentarOdgovorVrh">
    <div class="pomjeriBlokDaoDatum">
    <div class="komentarOdgovorDao"><?php echo $komentar_dodao; ?> </div>
    <div class="komentarOdgovorDatum">Dodan: <?php $komentar_datum = $komentar_datum; echo date('d.m.Y - H:i:s', strtotime($komentar_datum)); ?></div>
    </div>
    <div class="komentarGlasanje">+155</div> 
    </div>
    <div class="ciscenje"></div>
    <div class="komentarSadrzaj">
    <?php echo $komentar_sadrzaj; ?>
      </div>
      <div class="kometarOpcije">
    <div class="komentarGore"> <a href="#">(15) Slažem se</a></div>
    <div class="komentarDole"> <a href="#">(35) Ne slažem se</a></div>
    <div class="komentarDrustveno">
    <div class="komentarPodijeli komentarLink"> <a href="#">Podijeli</a></div>
    <div class="komentarPrijavi komentarLink"> <a href="#">Prijavi</a></div>
    <div class="komentarOdgovori komentarLink"> <a href="#">Odgovori</a></div>
    </div>
    <div class="ciscenje"></div>
      </div>
    </div>
    <?php } ?>
    
    <!--- MARKUP FOR COMMENT REPLY --->
    <div class="odgovorNaKomentarOkvir">
    <div class="odgovorNaKomentarSlika"><img src="slike/01.jpg" alt="Mountain View"></div>
    <div class="odgovorNaKomentarVrh">
    <div class="odgovorNaKomentarPomjeriBlokDaoDatum">
    <div class="odgovorNaKomentarDao">TestName</div>
    <div class="odgovorNaKomentarDatum">Dodan: 27.01.2016 - 00:18:56</div>
    </div>
    <div class="odgovorNaKomentarGlasanje">+5</div> 
    </div>
    <div class="ciscenje"></div>
    <div class="odgovorNaKomentarSadrzaj">
    Test content
      </div>
      <div class="odgovorNaKomentarOpcije">
    <div class="odgovorNaKomentarGore"> <a href="#">(15) Slažem se</a></div>
    <div class="odgovorNaKomentarDole"> <a href="#">(35) Ne slažem se</a></div>
    <div class="odgovorNaKomentarDrustveno">
    <div class="odgovorNaKomentarPodijeli odgovorNaKomentarLink"> <a href="#">Podijeli</a></div>
    <div class="odgovorNaKomentarPrijavi odgovorNaKomentarLink"> <a href="#">Prijavi</a></div>
    <div class="odgovorNaKomentarOdgovori odgovorNaKomentarLink"> <a href="#">Odgovori</a></div>
    </div>
    <div class="ciscenje"></div>
      </div>
    </div>
    
    
    </div> 
    <!--- Komentari --->

    How it should look like on the attached picture.

    post-192985-0-94462900-1454545896_thumb.jpg

  2. Hello Community,
     
    I have some diffuclties about getting the right logic for article management with subcategories. So everything with Categorys is fine.
     
    TABLE: articles    
    articleID
        title
        content
        cat_relatedID
     
    TABLE: categories 
        catID
        cat_name
     
    On submit it Works fine where in "selection option" I can select the Category for that post. Now I want to extend it with subcategories.
     
    TABLE: articles      
        articleID
        title
        content
        cat_relatedID
     
    TABLE: categories     
        catID
        cat_name
     
    TABLE: subcategories 
        subcatID
        subcat_name
        related_catID
     
    Now the problem is how to relate Cats and Subcats in the form where I am adding new Articles and submit it to mysql. Do I need a additional field in the article table subcatID or anything else? My logic is something to make like in Wordpress when adding New posts you have the option to check categories related with that post. 
     
     

        <ul class="list-unstyled categorychecklist ">
            <li><input type="checkbox" value=""> Category 1
                <ul class="children">
                    <li><input type="checkbox" value=""> Subcategory 1</li>
                    <li><input type="checkbox" value=""> Subcategory 2</li>
                    <li><input type="checkbox" value=""> Subcategory 3</li>
                </ul>        
            </li>    
            <li><input type="checkbox" value=""> Category 2
                <ul class="children">
                    <li><input type="checkbox" value=""> Subcategory 4</li>
                    <li><input type="checkbox" value=""> Subcategory 5</li>
                    <li><input type="checkbox" value=""> Subcategory 6</li>
                </ul>        
            </li>
            <li><input type="checkbox" value=""> Category 3 - No subcategories</li>
        </ul>  
    

     LINK should look something like this example:

     mylink.com/category.php?ID=12&sub_ID=15

     

    Image attached is how it looks now.

    post-192985-0-12405400-1453979979_thumb.jpg

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.