login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > PHP > Snippets > MySQL tabel viewer

MySQL tabel viewer

Auteur: XenoX - 19 augustus 2004 - 16:40 - Gekeurd door: Dennisvb - Hits: 5455 - Aantal punten: 3.00 (1 stem)




Vul de database gegevens plus een mysql tabel in en je ziet de inhoud van de tabel.

Code:
tabelviewer.php:
  1. <center>
  2. <?php
  3. if(IsSet($_POST['Mysql'])) {
  4. mysql_connect($_POST['Mysql']['Host'], $_POST['Mysql']['User'], $_POST['Mysql']['Pass']);
  5. mysql_select_db($_POST['Mysql']['Db']);
  6.  
  7. $query = mysql_query("SELECT * FROM ".$_POST['Mysql']['Table']) or die(mysql_error());
  8.  
  9. while($tabel = mysql_fetch_array($query)) {
  10. echo "<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\">\n";
  11.  
  12. foreach($tabel as $VeldNaam => $VeldInhoud) {
  13. if(!is_int($VeldNaam)) {
  14. echo " <tr>\n";
  15. echo " <td>".$VeldNaam."</td>\n";
  16. echo " <td>".$VeldInhoud."</td>\n";
  17. echo " </tr>\n";
  18. }
  19. }
  20.  
  21. echo "</table>\n<br>\n";
  22. }
  23.  
  24. echo "<a href=\"".$_SERVER['REQUEST_URI']."\">Overnieuw</a>";
  25. } else {
  26. ?>
  27. <form method="post">
  28. <table border="1" cellpadding="5" cellspacing="0">
  29. <tr>
  30. <td>MySQL Host:</td>
  31. <td><input type="text" name="Mysql[Host]" size="25"></td>
  32. </tr>
  33. <tr>
  34. <td>MySQL User:</td>
  35. <td><input type="text" name="Mysql[User]" size="25"></td>
  36. </tr>
  37. <tr>
  38. <td>MySQL Pass:</td>
  39. <td><input type="text" name="Mysql[Pass]" size="25"></td>
  40. </tr>
  41. <tr>
  42. <td>MySQL Db:</td>
  43. <td><input type="text" name="Mysql[Db]" size="25"></td>
  44. </tr>
  45. <tr>
  46. <td>MySQL Table:</td>
  47. <td><input type="text" name="Mysql[Table]" size="25"></td>
  48. </tr>
  49. <tr>
  50. <td colspan="2" align="center"><input type="submit" name="Mysql[Submit]" value="Bekijken"></td>
  51. </tr>
  52. </table>
  53. </form>
  54. <?php
  55. }
  56. ?>
  57. </center>
Download code! Download code (.txt)

 Stemmen
Niet ingelogd.

 Reacties
Post een reactie
Lees de reacties (1)
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.024s