Create new "panel" dynamically with php and mysql

Asked

Viewed 36 times

0

I am developing a hotel system and I want to represent each apartment registered in the system with a panel containing information, that is, for each apartment the system generates a new panel that is displayed to the user. This is the structure of the panel

        <div class="col-md-4">
            <div class="panel panel-default">
                <div class="panel-heading">201(numero do quarto)
                    <span class="pull-right clickable panel-toggle"><em class="fa fa-toggle-up"></em></span></div>
                <div class="panel-body">
                    <p>(Aqui vai o conteudo do panel)</p>
                </div>
            </div>
        </div>

Remembering that in each panel should display the number of the apartment and whether or not it is busy. I hope you’ve made me understand what I’m trying to do

  • Simply select all the records from your database, loop through them all, and for each, generate the desired HTML code. Want to try?

1 answer

-1


I don’t really understand what you’re trying to do, but if you want the program to create these panels with php, I would use something like this:

<?php
$array = array[$query];
$apartamentos = $array[0];
//$query seria o comando para selecionar os apartamentos, algo que poderia ter incrementeado

for($i=0;$i<$apartamentos;$i++)
echo ' <div class="col-md-4">
        <div class="panel panel-default">
            <div class="panel-heading">'.$apartamento[$i].'
                <span class="pull-right clickable panel-toggle"><em class="fa fa-toggle-up"></em></span></div>
            <div class="panel-body">
                <p>(Aqui vai o conteudo do panel)</p>
            </div>
        </div>
    </div>';
  • Here is just an example of how to do the repetition. I did not understand the rest because it was not clear.

  • That’s pretty much it, buddy. Thanks, I’ve got the logic and follow here!

Browser other questions tagged

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