Os dejo todo mi codigo:
Código PHP:
Ver original<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Case</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>
<?php
$num=0;
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB2";
$r2=0;
$time=0;
$i2=$i3=0;
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error); }
$sql = "SELECT id,imagen1, names,contador,time FROM basico ";
$result = $conn->query($sql); //query envia una consulta con las variables especificadas en la variable mayor
while($row = $result->fetch_assoc()){ //*
$i2=$i2+1;// calculo cuantas imagenes habra
}//*
$num=$i2/2;
echo $i2;
?>
<div class="container">
<h2>Dynamic Tabs</h2>
<ul class="nav nav-tabs">
<?php
for($i=0; $i<$num; $i++) {
if($i==0){echo "<li>"."<a data-toggle='tab' href='#home'>pagina1</a>"."</li>";}
if(($i) % $num != 0) {
$i=$i+1;
echo "<li>"."<a data-toggle='tab' href='#home$i'>pagina$i</a>"."</li>";
$i=$i-1;
}//if
}//for
?>
</ul>
<div class="tab-content">
<div id="home" class="tab-pane fade in active">
<h3>HOME</h3>
<?php
$sql = "SELECT id,imagen1, names,contador,time FROM basico ";
$result = $conn->query($sql); //query envia una consulta con las variables especificadas en la variable mayor
$i3=0;
while($row = $result->fetch_assoc()){ //*
if($i3<2){
$r2=$row["contador"];
$time=$row["time"];
if($time>-0.1){
$online="En linea !";
}else{ $online= "Desconectado";}
echo "<div id='primera'>"."<a href='http:perfilex.php?contador=$r2'>".'<img height="150" width="150" src="data:image;base64,'.$row["imagen1"].' "> '."<br>".$row["names"]."</a>"."<br>".$online."</div>";
$i3=$i3+1;
}else
{
$i3=$i3;
}
}//*
?>
</div>
</div>
</div> <!--container-->
</body>
</html>