Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

21 May 2014

PHP Mysql table preview without column names.

Chestia asta preia din orice tabela mai intai header-ul, apoi toate inregistrarile si le afiseaza intr-un tabel.
Este foarte potrivita pentru o afisare a bazei de date pentru ca nu trebuie sa mai scrieti peste tot $rand['nume' ,$rand['prenume....etc...
 
Modificati-o pentru a fi compatibila cu cerintele voastre. Sau numele campului ce selecteaza tabelul din Baza de date sa se numeasca "t".
 
 
$_SESSION['table']=$_POST['t'];
$tabel=$_SESSION['table'];
$result = mysqli_query($_SESSION['con'],"SELECT * FROM $tabel");
$e = mysqli_num_fields($result);
 
echo "<table border='1'>";
$i = 0;
echo "<tr>";   
while($i<$e)
{
$meta=mysqli_fetch_field($result);
 
  echo "<th>".$meta->name."</th>";
$i++;
}
echo "</tr>";
 
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
for($i=0;$i<$e;)
{
echo "<td>" . $row[$i] . "</td>";
$i++;
}
echo "</tr>";
}
echo "</table>";

CCSuite - CC Monitoring, CC Reports and AliveCheck

CC Monitoring, CC Reports and AliveCheck Create together a powerful application, user friendly, that helps managing, monitoring ...