Show php data inside tabs

-1

I have a question regarding the tabs. Previously I had the data to be shown all inside a table with pagination.

Now my doubt is. with the divisions of the tabs I have to open and close the php whenever I change tab? How can I do paging with the tabs?

Before this,      

include("conectar.php");

$quantidade = 1;
$pagina = (isset($_GET ['pagina'])) ? (int)$_GET['pagina'] : 1;
$inicio = ($quantidade * $pagina) - $quantidade;
$sql = "select * from Tables order by tb_trabalhador.id asc LIMIT $inicio,   $quantidade"  ;
    $qr = mysql_query($sql) or die(mysql_error());
    while($exibe = mysql_fetch_array($qr)){
    echo "<table>"; 

    echo  "<tr><td>Nome:</td>";
    echo "<td>".$exibe["Nome"]."</td></tr>";

    echo  "<tr><td>Morada:</td>"; echo "<td>";
    if ($exibe['Morada']){ echo $exibe['Morada'];}else{echo 'N/D';} echo "</td></tr>";

     echo  "<tr><td>Distrito:</td>"; echo "<td>";
     if ($exibe['Distrito']){ echo $exibe['Distrito'];}else{echo 'N/D';} echo "</td></tr>";

     echo  "<tr><td>Concelho:</td>"; echo "<td>";
     if ($exibe['Concelho']){ echo $exibe['Concelho'];}else{echo 'N/D';} echo "</td></tr>";

Now I have this without being filled:

  <div id="tabs-1">
    <p>Content for Tab 1</p>
</div>
<div id="tabs-2">
    <p>Content for Tab 2</p>
</div>
<div id="tabs-3">
    <p>Content for Tab 3</p>
</div>
    
asked by anonymous 15.04.2014 / 13:45

2 answers

1

Your PHP should look like this:

$i = 1;
while($exibe = mysql_fetch_array($qr)){
echo"
<div id='tabs-".$i."'>
    <p>".$exibe['Morada']."</p>
    <p>".$exibe['Distrito']."</p>
    <p>".$exibe['Concelho']."</p>
</div>
";
$i++;
}

The variable $i is counting the CSS that you are applying, for each WHILE that returns for verification, it adds +1 , so when you finalize the information it will put every CSS % not in place. If you have to load a lot of information into TABS , then ECHO must be done for each TABS .

    
15.04.2014 / 14:05
0

Hello. The best paging option is with data set from $inicio and $limite making only query of desired data SELECT lista FROM tablet LIMIT $inicio,$limite . And you still get performance performance.

An example:

I think this is it:
<?php
include("conectar.php");

$quantidade = 1;
$pagina = (isset($_GET ['pagina'])) ? (int)$_GET['pagina'] : 1;
$inicio = ($quantidade * $pagina) - $quantidade;
$sql = "select * from Tables order by tb_trabalhador.id asc LIMIT $inicio,   $quantidade"  ;
    $qr = mysql_query($sql) or die(mysql_error());
    while($exibe = mysql_fetch_array($qr)){

    //verificação sequencial. 
    if (!empty($exibe['Morada'])){ 
      $morada = 'N/D';
    }else{
      $morada = $exibe['Morada']
    }
    if (!empty($exibe['Distrito'])){ 
      $distrito = 'N/D';
    }else{
      $distrito = $exibe['Distrito']
    }
    if (!empty($exibe['Concelho'])){ 
      $conselho = 'N/D';
    }else{
      $conselho = $exibe['Concelho']
    }

    echo'<div id="tabs-1">
           <p>Nome: '.$exibe["Nome"].'</p>
           <p>Morada:   '.$morada.'</p>
           <p>Distrito: '.$distrito.'</p>
           <p>Concelho: '.$conselho.'</p>
         </div>';
 }
?>   
    
15.04.2014 / 15:45