• 11-03-2023, 17:26:30
    #1
    Merhaba php kısmında yardıma ihtiyacım var veri tabani bağlantısını doğru yapmıştım ama sistem arama çalışmadı nasıl yapabilirim kodları düzeltip bana buradan atabilir misiniz?

    <?php
        
        include "scripts/perf_start.php";
        
        session_start();
        
        require_once "app.php";
        require_once "scripts/lang-switch.php";
        
        require_once "scripts/login_helpers.php";
        redirect_visitor("login.php?ref=" . $app["rel_req"]);
        
        require_once "scripts/session.php";
        $member = session_get_member();
        
    ?>
    <!DOCTYPE html>
    <html lang="tr">
    
    <head>
        <meta charset="utf-8" />
        <title><?= _t("Dosyalar") ?></title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <base href="<?= $app["url"] ?>/" />
        <link rel="icon" type="image/x-icon" href="favicon.ico" />
        <link rel="stylesheet" href="css/styles.css" />
        <link rel="stylesheet" href="css/header.css" />
        <link rel="stylesheet" href="css/dashboard.css" />
        <link rel="stylesheet" href="css/files.css" />
    </head>
    
    <body>
    
        <?php
            $page = "files";
            include "template/header.php";
        ?>
        
        <main>
            <div class="container">
                
    <?php
        
        session_print_error("download_id_invalid");
        session_print_error("download_db_missing");
        
        require_once "scripts/tools.php";
        
        if (is_approved()) {
            
            session_print_error("action_delete_file");
            session_print_message("action_delete_file");
            
            require_once "db/connection.php";
            require_once "models/FileUploadAgent.php";
            
            $fileupload_agent = new FileUploadAgent($db_agent->pdo);
            
            $files = [];
            
            require_once "scripts/requests.php";
            
            $id = GET("id");
            
            if ($id && preg_match('/^\d+$/', $id, $match)) {
                $file = $fileupload_agent->get_file_by_id($id);
                if ($file) {
                    $files = [$file];
                } else {
                    echo "Dosya bulunamadı.";
                }
            } else {
                $files = $fileupload_agent->get_files();
                $count = count($files);
                if ($count != 0) {
                    echo "<span class='count'>{$count} " . _t("dosya bulundu") . ".</span>";
                } else {
                    echo _t("Yüklü herhangi bir dosya bulunamadı.");
                }
            }
        
            if ($files) {
                
                require_once "scripts/element.php";
                
                $table = elem("table", null);
                $thead_rows = [];
                
                if (is_admin()) {
                    $thead_rows[] = elem("td", ["class"=>"op"], "İşlemler");
                }
                $thead_rows[] = elem("td", ["class"=>"file"],         _t("Dosya"));
                $thead_rows[] = elem("td", ["class"=>"size"],         _t("Boyut"));
                $thead_rows[] = elem("td", ["class"=>"thumbnail"],    _t("Ön İzleme"));
                $thead_rows[] = elem("td", ["class"=>"description"],  _t("Açıklama"));
                if (is_admin() || is_mod()) {
                    $thead_rows[] = elem("td", ["class"=>"date"],   "Yüklenme Tarihi");
                    $thead_rows[] = elem("td", ["class"=>"email"],  "Yükleyen");
                }
                
                $thead = elem("thead", null, elem("tr", null, $thead_rows));
                $table->append($thead);
                
                for ($i = 0; $i < count($files); $i++) {
                    $file = $files[$i];
                    
                    $thumbnail = "";
                    if ($file["thumbnail"]) {
                        $thumbnail = elem("a", ["href"=>"uploads/images/". $file["thumbnail"], "target"=>"_blank"], elem("img", ["src"=>"uploads/images/". $file["thumbnail"], "class"=>"thumbnail"]));
                    }
                    
                    $file_link = elem("a", ["href"=>"download.php?id=" . $file["id"], ], $file["name"]);
                    
                    $file_size = number_format(intval($file["size"]) / 1024, 2);
                    $file_size = elem("span", ["title"=>"{$file["size"]} KB"], $file_size . " MB");
                    
                    $cells = [];
                    if (is_admin() || is_mod()) {
                        if (is_admin()) {
                            $cells[] = elem("td", ["class"=>"op"], elem("a", ["href"=>"actions/delete_file.php?id={$file["id"]}&ref=files.php", "class"=>"button-chrome delete", "title"=>"Dosyayı Sil"], elem("img", ["src"=>"images/bin.png"])));
                        }
                    }
                    $cells[] = elem("td", ["class"=>"file"], $file_link);
                    $cells[] = elem("td", ["class"=>"size"], $file_size);
                    $cells[] = elem("td", ["class"=>"thumbnail"], $thumbnail);
                    $cells[] = elem("td", ["class"=>"description"], $file["description"]);
                    if (is_admin() || is_mod()) {
                        $cells[] = elem("td", ["class"=>"date"], $file["upload_date"]);
                        // $cells[] = elem("td", ["class"=>"email"], "asd");
                        
                        global $db_agent;
                        
                        $member_agent = new MemberAgent($db_agent->pdo);
                        
                        $uploader = $member_agent->get_member_by_id($file["uploader_id"]);
                        if ($uploader) {
                            $target_page = "users";
                            if ($uploader["role"] == "administrator") {
                                $target_page = "admins";
                            } else if ($uploader["role"] == "moderator") {
                                $target_page = "mods";
                            }
                            $uploader_link = elem("a", ["href"=>"{$target_page}.php?id=" . $uploader["id"]], $uploader["email"]);
                        } else {
                            $uploader_link = elem("span", ["title"=>"ID : {$file["uploader_id"]}"], $file["uploader_email"]);
                        }
                        $cells[] = elem("td", ["class"=>"email"], $uploader_link);
                    }
                    $row = elem("tr", null, $cells);
                    $table->append($row);
                }
                
                $table->output();
                
            }
            
        } else {
            echo "<p>Hesabınız henüz onaylanmamış.</p>";
            echo "<p>Dosyaları hesabınız onaylandığında görüntüleyebilirsiniz.</p>";
        }
        
    ?>
    
            </div>
        </main>
        <script src="https://code.jquery.com/jquery-3.5.1.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js"></script>
        
        <script>
            document.querySelectorAll(".delete").forEach(function (a) {
                a.addEventListener("click", function (e) {
                    e.preventDefault();
                    if (confirm("Dosya silinecek. Devam edilsin mi?")) {
                        location.href = this.href;
                    }
                });
            });
        </script>
            </section>
    </body>
    </html>
    <tbody>
    <form action="" method="GET">
                                        <div class="input-group mb-3">
                                            <input type="text" name="search" required value="<?php if(isset($_GET['search'])){echo $_GET['search']; } ?>" class="form-control" placeholder="Search">
                                            <button type="submit" class="btn btn-primary">Arama</button>
                                        </div>
                                    </form>
    <?php 
    
                                        $con = mysqli_connect("localhost","user","password!","database");
    
                                        if(isset($_GET['search']))
                                        {
                                            $filtervalues = $_GET['search'];
                                            $query = "SELECT * FROM users WHERE CONCAT(id,name,size,description) LIKE '%$filtervalues%' ";
                                            $query_run = mysqli_query($con, $query);
    
                                            if(mysqli_num_rows($query_run) > 0)
                                            {
                                                foreach($query_run as $items)
                                                {
                                                    ?>
                                                    <tr>
                                                        <td><?= $items['id']; ?></td>
                                                        <td><?= $items['name']; ?></td>
                                                        <td><?= $items['size']; ?></td>
                                                        <td><?= $items['description']; ?></td>
                                                        <td><?= $items['thumbnail']; ?></td>
                                                    </tr>
                                                    <?php
                                                }
                                                
                                            }
                                            else
                                            {
                                                ?>
                                                    <tr>
                                                        <td colspan="4">No Record Found</td>
                                                    </tr>
                                                <?php
                                            }
                                        }
                                    ?> 
                                    </tbody>
    <?php
        session_delete("errors", "messages");
        include "scripts/perf_end.php";
  • 11-03-2023, 17:32:19
    #2
    Merhaba,

    Sizin paylaştığınız kodlarda bir hata olmadığı görünüyor, ancak arama sonucunu gösteren tablo kodlarının yanlış yere yerleştirildiği için çalışmamış olabilir.

    Kodların doğru şekilde çalışabilmesi için, arama formunun doğru bir şekilde açıldığından emin olmanız gerekiyor. Arama formu, `<tbody>` etiketi içinde yer almalıdır. Ancak sizin paylaştığınız kodlarda form, `</html>` etiketi ve `</tbody>` etiketleri arasında yer almaktadır. Doğru sıralamayı sağlamak için aşağıdaki gibi düzenleyebilirsiniz:

    ```
    ...
    <tbody>
    <tr>
    <td colspan="5">
    <form action="" method="GET">
    <div class="input-group mb-3">
    <input type="text" name="search" required value="<?php if(isset($_GET['search'])){echo $_GET['search']; } ?>" class="form-control" placeholder="Search">
    <button type="submit" class="btn btn-primary">Arama</button>
    </div>
    </form>
    </td>
    </tr>
    <?php
    $con = mysqli_connect("localhost","user","password!","dat abase");
    if(isset($_GET['search'])) {
    $filtervalues = $_GET['search'];
    $query = "SELECT * FROM users WHERE CONCAT(id,name,size,description) LIKE '%$filtervalues%' ";
    $query_run = mysqli_query($con, $query);
    if(mysqli_num_rows($query_run) > 0) {
    foreach($query_run as $items) {
    ?>
    <tr>
    <td><?= $items['id']; ?></td>
    <td><?= $items['name']; ?></td>
    <td><?= $items['size']; ?></td>
    <td><?= $items['description']; ?></td>
    <td><?= $items['thumbnail']; ?></td>
    </tr>
    <?php
    }
    } else {
    ?>
    <tr>
    <td colspan="5">No Record Found</td>
    </tr>
    <?php
    }
    }
    ?>
    </tbody>
    </table>
    ```

    Umarım bu çözüm işinizi görür.
  • 11-03-2023, 17:39:11
    #3
    muskmedya adlı üyeden alıntı: mesajı görüntüle
    Merhaba,

    Sizin paylaştığınız kodlarda bir hata olmadığı görünüyor, ancak arama sonucunu gösteren tablo kodlarının yanlış yere yerleştirildiği için çalışmamış olabilir.

    Kodların doğru şekilde çalışabilmesi için, arama formunun doğru bir şekilde açıldığından emin olmanız gerekiyor. Arama formu, `<tbody>` etiketi içinde yer almalıdır. Ancak sizin paylaştığınız kodlarda form, `</html>` etiketi ve `</tbody>` etiketleri arasında yer almaktadır. Doğru sıralamayı sağlamak için aşağıdaki gibi düzenleyebilirsiniz:

    ```
    ...
    <tbody>
    <tr>
    <td colspan="5">
    <form action="" method="GET">
    <div class="input-group mb-3">
    <input type="text" name="search" required value="<?php if(isset($_GET['search'])){echo $_GET['search']; } ?>" class="form-control" placeholder="Search">
    <button type="submit" class="btn btn-primary">Arama</button>
    </div>
    </form>
    </td>
    </tr>
    <?php
    $con = mysqli_connect("localhost","user","password!","dat abase");
    if(isset($_GET['search'])) {
    $filtervalues = $_GET['search'];
    $query = "SELECT * FROM users WHERE CONCAT(id,name,size,description) LIKE '%$filtervalues%' ";
    $query_run = mysqli_query($con, $query);
    if(mysqli_num_rows($query_run) > 0) {
    foreach($query_run as $items) {
    ?>
    <tr>
    <td><?= $items['id']; ?></td>
    <td><?= $items['name']; ?></td>
    <td><?= $items['size']; ?></td>
    <td><?= $items['description']; ?></td>
    <td><?= $items['thumbnail']; ?></td>
    </tr>
    <?php
    }
    } else {
    ?>
    <tr>
    <td colspan="5">No Record Found</td>
    </tr>
    <?php
    }
    }
    ?>
    </tbody>
    </table>
    ```

    Umarım bu çözüm işinizi görür.
    paylaşmış olduğum koda yerleştirme yapabilir misiniz? php den çok anlamıyorum ne yapcağımı bilmiyoum
  • 11-03-2023, 18:13:39
    #4
    muskmedya adlı üyeden alıntı: mesajı görüntüle
    Merhaba,

    Sizin paylaştığınız kodlarda bir hata olmadığı görünüyor, ancak arama sonucunu gösteren tablo kodlarının yanlış yere yerleştirildiği için çalışmamış olabilir.

    Kodların doğru şekilde çalışabilmesi için, arama formunun doğru bir şekilde açıldığından emin olmanız gerekiyor. Arama formu, `<tbody>` etiketi içinde yer almalıdır. Ancak sizin paylaştığınız kodlarda form, `</html>` etiketi ve `</tbody>` etiketleri arasında yer almaktadır. Doğru sıralamayı sağlamak için aşağıdaki gibi düzenleyebilirsiniz:

    ```
    ...
    <tbody>
    <tr>
    <td colspan="5">
    <form action="" method="GET">
    <div class="input-group mb-3">
    <input type="text" name="search" required value="<?php if(isset($_GET['search'])){echo $_GET['search']; } ?>" class="form-control" placeholder="Search">
    <button type="submit" class="btn btn-primary">Arama</button>
    </div>
    </form>
    </td>
    </tr>
    <?php
    $con = mysqli_connect("localhost","user","password!","dat abase");
    if(isset($_GET['search'])) {
    $filtervalues = $_GET['search'];
    $query = "SELECT * FROM users WHERE CONCAT(id,name,size,description) LIKE '%$filtervalues%' ";
    $query_run = mysqli_query($con, $query);
    if(mysqli_num_rows($query_run) > 0) {
    foreach($query_run as $items) {
    ?>
    <tr>
    <td><?= $items['id']; ?></td>
    <td><?= $items['name']; ?></td>
    <td><?= $items['size']; ?></td>
    <td><?= $items['description']; ?></td>
    <td><?= $items['thumbnail']; ?></td>
    </tr>
    <?php
    }
    } else {
    ?>
    <tr>
    <td colspan="5">No Record Found</td>
    </tr>
    <?php
    }
    }
    ?>
    </tbody>
    </table>
    ```

    Umarım bu çözüm işinizi görür.
    çalışmadı ama sistem bakabilir misiniz?