EG Information

Main Index
EG Manual
Disclaimer
Legal Information
Hall of Fame
Hall of Shame
Member Rankings
Members List
Meet the Staff

Training Missions

Read Me First
Basic Skills
Realistic Scenarios
Cryptography
Software Cracking
Linux ELF Binary Cracking
Logical Thinking
Programming
Captcha Cracking
Patching
Steganography
Deface This Wall
/dev/null
/dev/urandom
/dev/extra

Knowledge Bank

Discussion Forums
Exploit Database New
PasteBin New
RSS Feeds RSS
Articles / Tutorials
Videos
Online EG MP3 Player Radio
Downloads
Tools

Code Resources

Submit Code
Ajax
ASM
Bash
C
CPP
Csharp
Delphi
Haskell
Java
Javascript
Jython
Lisp
mIRC
MySQL
Perl
PHP
Python
QBASIC
VisualBasic

Pimp Us Out!

Review enigmagroup.org on alexa.com

Has Enigma Group Helped You? Then Help Us By Advertising For Us. Place One Of The Following Images On Your Site And Create A Link Back To Enigma Group.

Enigma Group

Enigma Group

Enigma Group

Enigma Group

 

Affiliates



The Urinal

hackhound.org

suck-o.com

hack.org.za

flyninja.net

 

Enigma Group's Code Bank


SQL Table to HTML Table Function

By: Teksaid  -  Date Submitted: 2008-11-20 03:23:51

  1. <?php
  2. /******************
  3. * Purpose: Function used to take all the data from a mySQL table
  4. * and create a HTML table display the information .
  5. * Authoer: Teksaid
  6. *******************/
  7.  
  8. // Parameters: mySQLi Connection Object and name of table to display
  9. function htmlTable($connObj, $tableName) {
  10.  
  11. // Query to grab all the table DATA
  12. $tableQuery = "SELECT * FROM " . $tableName;
  13. // Store the results of the query
  14. $tableResults = $connObj->query($tableQuery) or die($connObj->error);
  15.  
  16. // Grab all the column names for the column headers of the HTML table
  17. $colNames = $tableResults->fetch_fields();
  18. echo " <table id='{$tableName}' class='dataTable'>
  19. <tr colspan='2'>";
  20. // Loop through columns names to create column headers
  21. foreach($colNames as $val) {
  22. echo "<td>" .$val->name. "</td>";
  23. }
  24. echo " </tr>";
  25.  
  26. // Put results into an array and loop through until the end of the array
  27. while($tableArray = $tableResults->fetch_assoc()) {
  28. echo "<tr>";
  29. // Loop through columns names to grab each columns corresponding data from results array
  30. foreach($colNames as $val) {
  31. echo "<td>" .$tableArray[$val->name]. "</td>";
  32. }
  33. echo "</tr>";
  34. }
  35. }
  36.  
  37. //////////////////////// EXAMPLE //////////////////////
  38.  
  39. // Creating connection object with mySQL informatoin
  40. $connObj = new mysqli('localhost', 'user', 'pass', 'database');
  41.  
  42. // Calling the output function to display the HTML table
  43. // for the table users from the database in the connection object.
  44. htmlTable($connObj, 'users');
  45.  
  46. ///////////////////////////////////////////////////////
  47. ?>
Return to php category list

Who Visited EnigmaGroup Today?

1557 Guests, 262 Users (178 Spiders)
learning, aurena, suetekh, Hessesian, Rex_Mundi, st3alth, Partisan, hackaday, K0gller, fitz, 3ntr0py, DrOptix, Jayjay, JohnMalkovitzch, psychomarine, whoami, nmobin27, Vspectrum, lotato, San Marino, TinCardinal, brunoriversyhn, TheHarrisonW, code-g, yshiau, BillTuer, Psiber_Syn, Klosse, Seasharp, whisperer, obencefoozy, SlayingDragons, Link-, tinuigimeni, jasonbourne, Fred, GothicLogic, strudels, somebody777, Meonkzt, CJ_Omaha, jearrorne, cls777, unsugsNashy, Balksnuntails, trueorfalse, Sir D. Naut, zach, batsbargy, Rik, Macabre, ellisp, Nightraven, Iccyx, Repuhlsive, vipervince2002, Janomatrix, lol, veceattainc, techno, Exclaw, limited, Nikhil, evjfvir967nj, blackknight911, Distorted, Mod777, dark_void, nermtode, Tjm, bjy1997, hecky, saraf, elprof, damoniceht, trik, jordan86, SnoopSky, dan_movie, OnetInsolefon, Blavatsky, darkfire1515, seojlhmyrhwh, Thoplehap, MaxMeier, 1028rajeev, Abhinav2107, autotuneuser, riesenjoe, alexelixir, Tauya, Jozinbrejl, kernel_mod, quolc, anandoump, vladavlada, Taicadine, valy1177, AnnaNoult, GreenTiger, baripadatimes, Ewing, Blackbeard, thepuppeteer, BON-SELE, hak4r, Unotohumsmush, NIGHTWOLF, CloverCipher, m4f10, Vengeance987, avacraft, Bumpadjuppy, becool, thecoder, ddxc, n01se, alpha1, saki, ObesseJew, ActictGlync, sajan, unicornrainbow, Domihoolbob, matt.14, max66, SnowFury, Spud101, myfabregas, Ausome1, kajman121, Frudopvia, ideveloper6, OLOLO, Bugshuppy, lamb, VagWirura, LialiTiTviors, Ordeptpen, scifics, Pozycj-Z21, RomeoG, Gkjt, interPuscruse, aaftab, TheCheeseDemon, blackcyxx21, jollyjimbo, N4g4c3N, rineDriekly, Rap70r, Xargos, flarornEral, ovetz13, sonu sahu, Breezy, emitleBen, Hackpad, JWTSR, nicyun, kaizo, itevainee, IvanDimitriev, advilapyday, luke460, AverageJoe, zeratu92, m0rt, litbk, Mr.Pickle, mannavard1611, LoopyLion, NexusVos, lonely.connection, mtroscheck, burberrybagsjr, nikedunksxm, xordux, jeho, Lonewolf034, Dragonite, nhorton, Reloaded, Odile, Kaptain_k1rk, Teefelltugh, grizzly, posthuman01, jakesboy2, pwnpwnlolz, Sabo, Lakhoamnmek, Røgue, dot_Cipher, mori, snickerless1, cart1m, Xendz, KELATALFTUS, hubris, Afrika, welepocourl, carpinteyrofbt, ReottphoffBom, Reahastegah, pumashoesld, pdanielt, dmac006, DnA-Ender, Red Fox, couptupleakb, ryanjcrook, iMaxx, sh3llcod3, TimHortons, EmilaHapsaums, Feld Grau, burgeoningneophyte, Maroonhat, CookieAu, tinkansinar, Mitodina, timberlandoutletlufc, zsefvy, guccioutletox, AlexDiru, AbercrombieFitchhl, Ryuske, r0z4, slchill, rospark, kalak55, Ph4Kt480ii, beefarn, Jigoku, WrossyJes, pollolololo, ZepSung, Fragility, jell0, C9019, Othrguy, Noticon, KIKNWING, llasarus, mdubz, leah027, iellswo, MAZI_, Estilaamoli, subtentar, Trollorful, no, nas0151, Traybo, howisthechicken, thethird3y3, Somethingclever, marplusz, MSI52, twink gay cam dUi8D, temoJessy
 
Enigma Group