Feed increase alone - php

Asked

Viewed 20 times

0

I’m creating a forum and want to put x posts on it, but I want more posts to load when the user scrolls down to the bottom of the page (like twitter), does anyone know how I can do that? And I have another error tbm, my publications only appear when I create a new post, before that appears this "Notice: Undefined variable: resultado_usuarios in C: xampp htdocs forumvwxpress Vwxpress Views pages Volkswagen.php on line 145", if anyone can help me I will be very grateful!

<?php
$pdo = \VwXpress\MySql::connect();              

                $servidor = "localhost";
                $dbname = "vwxpress";
                $dbusuario = "eduardo";
                $dbsenha = "naninha1";
                $conn = mysqli_connect($servidor, $dbusuario, $dbsenha, $dbname);
                if (!$conn) {
                        die("conexao falhou: " . mysqli_connect_error());
                }

                if(isset($_POST['comentario'])){
                    $nome = trim(strip_tags($_POST['nome']));
                    $post = trim(strip_tags($_POST['comentario']));
                    $date = date('Y-m-d H:i:s');
    
                    $conn = mysqli_connect($servidor,$dbusuario,$dbsenha,$dbname);
                    mysqli_select_db($conn,'$dbname');
    
                    $query = "SELECT nome,post,date FROM posts LIMIT 15";
                    
                    $resultado_usuarios = mysqli_query($conn, $query);
    
                    $sql = ("INSERT INTO posts (nome,post,date) VALUES ('$nome', '$post', '$date')");
    
                    $pagina_atual = filter_input(INPUT_GET,'pagina', FILTER_SANITIZE_NUMBER_INT);
    
                    $pagina = (!empty($pagina_atual)) ? $pagina_atual : 1;
    
                    $qnt_result_pg = 2;
    
                    $inicio = ($qnt_result_pg * $pagina) - $qnt_result_pg;
    
                    $result_pg = "SELECT COUNT(id) AS num_result FROM usuario";
                    $resultado_pg = mysqli_query($conn, $result_pg);
                    $row_pg = mysqli_fetch_assoc($resultado_pg);
    
                    $quantidade_pg = ceil($row_pg['num_result'] / $qnt_result_pg);
    
                    $max_links = 2;}

?>

<!DOCTYPE html>
<html>
<head>
    <title>Bem vindo, <?php echo $_SESSION['nome']; ?></title>
    <script type="text/javascript">
    function criarPost()
    {document.getElementById('divTeste').style.display = 'block';}
    </script>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width;initial-scale=1.0;maximum-scale=1.0">
    <link rel="stylesheet" href="<?php echo INCLUDE_PATH_STATIC ?>estilos/estilo.css">
    <link rel="stylesheet" href="<?php echo INCLUDE_PATH_STATIC ?>estilos/new.css">
    <meta name="keywords" content="peca,vw,porsche,kombi,importer">
    <link rel="stylesheet" href="<?php echo INCLUDE_PATH_STATIC ?>css/all.min.css">
    <link rel="preconnect" href="https://fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300&display=swap" rel="stylesheet">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascrip" src="main.js"></script></script>
    <link rel="preconnect" href="https://fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css2?family=Goblin+One&family=Itim&display=swap" rel="stylesheet">
</head>
<body>
    <header> <!--MENU DO SITE!-->
    <div class="container">
                <div class="pesquisa">
                    <h2><i class="fas fa-search"></i>Busque seu produto.</h2>
                </div>
                <div class="pesquisa">
                    <form class="inscricao-form">
                        <input type="text" name=""><input type="submit" name="acao" value="buscar!">
                    </form>
                </div>
                <div class="logo"><h2>VWXPRESS</h2></div>
                <nav class="menu-desktop">
                    <ul class="kekw">
                        <li class="selected"><a href="<?php echo INCLUDE_PATH ?>home">Home</a></li>
                        <div class="dropdown">
                        <a href="<?php echo INCLUDE_PATH ?>home" class="dropbtn">Forum<i class="fas fa-angle-down icon-menu"></i></a>
                        <div class="dropdown-content">
                            <a href="<?php echo INCLUDE_PATH ?>volkswagen">Volkswagen</a>
                            <a href="<?php echo INCLUDE_PATH ?>porsches">Porsches</a>
                            <a href="<?php echo INCLUDE_PATH ?>alemaes">Alemaes</a>
                            <a href="<?php echo INCLUDE_PATH ?>pecas">Pecas</a>
                            <a href="<?php echo INCLUDE_PATH ?>mecanica">Mecanica</a>
                        </div>
                        </div>
                        <li><a href="<?php echo INCLUDE_PATH ?>login">Login</a></li>

                        <li><a href="?loggout">Loggout</a></li>
                    </ul>
                </nav>
                <div class="clear"></div>
        </div>
    </header>

    <div class="container">

        <!--navigation!-->

        <div class="navigate">
            <span><a href="<?php echo INCLUDE_PATH ?>home">Forum</a> >> <a href="<?php echo INCLUDE_PATH ?>volkswagen">Volkswagen</a> <a onclick='criarPost()' value='Inserir texto' style="float:right; cursor:pointer;">Criar post</a></span>
        </div>

        <div class="post-local" id="divTeste" style="display:none;">
            <form method="post" action="#">
                <textarea name="comentario"></textarea>
                <input type="hidden" name="post_feed">
                <p style="font-weight:bold">Seu nome:</p><input type=text name="nome"  required>
                <div>
                        <h4>Categoria:</h4>
                        <form method="post" action="cadastrar-enquete.php>" onsubmit="Checkfiles(this)">
                        <select name="time">
                            <option value="bota">Volkswagen</option>
                            <option value="bota">Alemaes</option>
                            <option value="bota">Pintura</option>
                            <option value="bota">Pecas</option>
                            <option value="bota">Mecanica</option>  
                        </select>
                </div>
                <div  style="margin-top: 10px">
                        <input id="filename'" type="file" name="arquivos" class="btn btn-success"  accept="image/png, image/jpeg"  multiple />
                </div>
                <div  style="margin-top: 10px"> 
                <input type="reset" value="Cancelar" />
                </div  style="margin-top: 10px">
                <input type="submit" name="newcoment" value="Postar!"  style="margin-top: 10px; color: white; font-weight: bold;">
            </form>
            
        </div>

        <div class="posts-table">
            <div class="table-head">
                <div class="status">Categoria</div>
                <div class="subjects" style="text-align: center;">Conteudo</div>
                <div class="replies">nome</div>
                <div class="last-reply">Ultima resposta</div>
            </div>

            <div class="posts-table">   
            <?php 
                while($row_usuario = mysqli_fetch_assoc($resultado_usuarios)){
             ?>
            <div class="table-row">
                <div class="status"><i class="fas fa-car"></i></div>
                <div class="subjects" name="post"><a href=""><?php echo $row_usuario['post'] . "<br>"; ?></a></div>
                <div class="replies" name="date"><?php echo $row_usuario['nome'] . "<br>"; ?></div>
                <div class="last-reply"><a href="<?php echo INCLUDE_PATH ?>perfil"><?php echo $row_usuario['date'] . "<br>"; ?></a></div>
            </div>
            <?php }?>
            

                <?php { ?>
            <div class="pagination">
                paginas: <a href="#"><?php ?></a><a href="#">2</a><a href="<?php  ?>">3</a>
            </div>
                <?php } ?>
            
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.