0

So i want to place this code below

 $keyword="";
    if (isset($_POST['searchpakaian'])) {
        $keyword = $_POST['searchpakaian'];
    }

    $query = mysqli_query($conn,"SELECT * FROM tbl_pakaian WHERE nama_pakaian LIKE '%".$keyword."%' ORDER BY id ASC limit 0,6");
    $hitung_data = mysqli_num_rows($query);
    if ($hitung_data > 0) {
    while ($row = mysqli_fetch_array($query)) { 
    ?>
    
    <div class="col">
        <div class="card h-100">
            <div class="card-img-wrap ">
                <img src="img/Galeri/pakaian/<?php echo $row['gambar_pakaian'] ?>" class="card-img-top" alt="...">
            </div>
            <div class="card-body">
                <h5 class="card-title"><?php echo $row['nama_pakaian'] ?></h5>
                <p class="card-text "><?php echo $row['keterangan_pakaian'] ?></p>
            </div>
        </div>
    </div>

<?php } } else { ?> 
    <center><h4>Tidak Ada Data</h4></center>
<?php } ?>

On if conditional statement

if($req == 'something'){

}

Here is my full code

<?php
    include '../koneksi.php';
    $req = $_REQUEST['req'];
    $keyword="";
    if (isset($_POST['searchpakaian'])) {
        $keyword = $_POST['searchpakaian'];
    }

    $query = mysqli_query($conn,"SELECT * FROM tbl_pakaian WHERE nama_pakaian LIKE '%".$keyword."%' ORDER BY id ASC limit 0,6");
    $hitung_data = mysqli_num_rows($query);
    if ($hitung_data > 0) {
    while ($row = mysqli_fetch_array($query)) { 
    ?>
    
    <div class="col">
        <div class="card h-100">
            <div class="card-img-wrap ">
                <img src="img/Galeri/pakaian/<?php echo $row['gambar_pakaian'] ?>" class="card-img-top" alt="...">
            </div>
            <div class="card-body">
                <h5 class="card-title"><?php echo $row['nama_pakaian'] ?></h5>
                <p class="card-text "><?php echo $row['keterangan_pakaian'] ?></p>
            </div>
        </div>
    </div>

<?php } } else { ?> 
    <center><h4>Tidak Ada Data</h4></center>
<?php } ?>

If i just copy the code to the if conditional statement code, it just say 'unexpected end of file'

What should i do?

1

1 Answer 1

1

The syntax error are vey simple to find just confirm that when you copy inside the if, dont repeat php keys as and the echo finish it with ;

<?php echo('hello world'); ?>

OR the same echo but simple deleting the php tag by = simbol (only work with echo)

<?= 'hello world' ?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.