Dynamic pages through request

0

I am putting together a web application in a way that future maintenance is simplified.

So, I started searching for dynamic pages, etc. But in practice, I do not even know how to start.

I wanted it to look like this:

  • header.php: header with side menu linking to other pages

  • content.php: (already done)

  • footer.php: (I've already done it)

In my index.php, I call the css, js, etc. files. And I give an include in header, content, footer ...

Folders:

  • lib /

  • application /

  • controllers /

  • template / header.php, content.php, footer.php

    • index.php
  • Up to that point ...

    In my header, in the menu, there are several links, but I did not want to have to create 15, 20 different pages. But yes, 1 page with the content for each link.

    How do I do this?

    I was wondering how I could do this, along with the database, in testing this almost everything going well, but it is not displaying my content.

    Here's how I did it:

    I created a table (tblPaginas), in it put the fields: id, name, controller, arg and ennable.

    id name     controller arg  ennable
    1  index                0     0
    
    2  pagina1     pag      1     1
    
    3  pagina2     pag      2     1
    
    4  pagina3     pag      3     1
    

    etc

    In my header, I put the following:

    <?php       
        echo '
            <li>
                        <a href="javascript:;">
                        <i class="icon-basket"></i>
                        <span class="title">PAGINAS</span>
                        <span class="arrow "></span>
                </a>';
    
        echo ' <ul class="sub-menu">';
    
                    $sql= ("SELECT * FROM tblPaginas where ennable = 1 and arg > '0' order by id ");
                    $query = mysql_query($sql);
                    while($row = mysql_fetch_array($query))
                    {
    
                    echo'                         
                        <li>
                                <a href="index.php?'.$row['controller'].'='.$row['arg'].'">
                                <text style="TEXT-TRANSFORM: uppercase;">'.$row['name'].' </text></a>
                        </li>' ;}
    
                        echo '</ul>';
                        echo '</li>';
    ?>
    

    So, it displays my side menu, taking the 'name' (page name in the menu), and sending the controller and arg through the URL.

    On my content.php page, I tried the following:

    <?php
    $uri = $_GET['arg'];
    
        $var = $uri;
        switch ($var)
    {
        case 1:
        include 'pag/geral.php';
        break;
    
        case 2:
        include 'pag/pagina2.php';
        break;
    
        case 3:
        echo "DEU CERTO O 3";
        break;
    }
    
    ?>
    

    But he is not displaying the pages, this code is not working this content page.

    I thought of doing so, as I can later try to make a control panel, and edit the pages by the bank.

    Can you help me make this code work?

        
    asked by anonymous 21.02.2015 / 16:28

    0 answers