Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function connection($serwer,$login,$pass,$db)
- {
- $conn=mysql_connect($serwer,$login,$pass,$db)
- or die("Blad poloczenia:".mysql_error());
- mysql_select_db($db);
- return $conn;
- }
- connection("localhost","16_widlak","U3s5r2k4e9","16_widlak");
- //część 1 - wyświetl tylko nazwy wszystkich tabel w swojej bazie `XX_nazwisko`
- function Bolt($query){
- $result=mysql_query($query) or die("Bład w zapytaniu $query: " . mysql_error());
- return $result;
- }
- $table=$_GET['table'];
- $showtables="SELECT * FROM ".$_GET['table'];
- $sort=$_POST['sort'];
- if (!isset($_GET['table']) || empty($_GET['table'])){
- $query="SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '16_kwiek'";
- $result = mysql_query ($query);
- while($row = mysql_fetch_array($result, MYSQL_NUM)) {
- echo "<a href=\"?table=".$row[0]."\">";
- foreach ($row as $elem) echo " $elem ";
- echo "</a>";
- echo "<br>";
- }
- }
- else {
- echo "<form method='get'> <input type='submit' value='--- BACK ---'> </form>";
- //część 4 - informacja kiedy tabela była ostatnio modyfikowana i ile dni temu została stworzona
- $query="SELECT UPDATE_TIME from information_schema.TABLES WHERE TABLE_NAME='$table' AND TABLE_SCHEMA='16_kwiek'";
- $result= Bolt($query);
- $row = mysql_fetch_array($result, MYSQL_NUM);
- echo "The table's last update was on: " .$row[0];
- echo "<br>";
- $query="SELECT current_date()-date(UPDATE_TIME) FROM information_schema.TABLES WHERE TABLE_NAME='".$table ."' AND TABLE_SCHEMA='16_kwiek'";
- $result= Bolt($query);
- $row = mysql_fetch_array($result, MYSQL_NUM);
- echo "The table was created: " .$row[0]. " days ago.";
- echo "<br>";
- }
- $sort=$_POST['sort'];
- $table=$_GET['table'];
- echo "<br><br><table ><tr>";
- //część 2 - wyświetlenie zawartości tabeli + część 3 - posortowanie tabeli
- if (empty ($_POST['sort'])){
- $query="SELECT * FROM $table";
- echo "$table";
- }
- else {
- $query="SELECT * FROM $table ORDER BY $sort;";
- echo "$table is sorted by $sort";
- }
- echo "</th></tr><br><tr><br>";
- $result = Bolt($query);
- while($column=mysql_fetch_field($result)){
- echo "<th><form action='' method='post'>";
- echo "<input type='hidden' value='".$column->name."' name='sort'><input type='submit' value='".$column->name."'>";
- echo "</form></th>";
- }
- echo "</tr><br>";
- while($row = mysql_fetch_array($result, MYSQL_NUM)) {
- foreach ($row as $elem) echo "<td>$elem</td>";
- echo "</tr>";
- }
- echo "</table>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement