cotede2 Posted June 20, 2009 Share Posted June 20, 2009 Hello , in PHP , I'd like with only a few lines to get all data from a table without the obligation to specify the number of fields and their names. I got like 200 fields multiply by 12 tables ... So if the structure is liek that: FName LName Age while($e = mysql_fetch_array($query)){ //code I am looking for } Displays Fname => dupond Lname => arthur Age => 18 .. thanks. Link to comment https://forums.phpfreaks.com/topic/163061-get-all-data-from-a-table-whatever-the-number-of-columns/ Share on other sites More sharing options...
RussellReal Posted June 20, 2009 Share Posted June 20, 2009 you could echo it into a javascript array, and have javascript push the raw data into a table, that will considerably cut down on the loading time.. since its javascript which is a client side language, so you'll be sending the MINIMAL amount of data, and the browser will handle it.. Link to comment https://forums.phpfreaks.com/topic/163061-get-all-data-from-a-table-whatever-the-number-of-columns/#findComment-860391 Share on other sites More sharing options...
cotede2 Posted June 20, 2009 Author Share Posted June 20, 2009 I dont get it . what javascript has to do with it? I could echo what? Link to comment https://forums.phpfreaks.com/topic/163061-get-all-data-from-a-table-whatever-the-number-of-columns/#findComment-860394 Share on other sites More sharing options...
cotede2 Posted June 20, 2009 Author Share Posted June 20, 2009 print_r is nice it displays a display with all the data. Array ( [0] => 548084 [MLSNumber] => 548084 [1] => 184900 [PriceListing] => 184900 [2] => BROADKILL HUNDRED [Area] => BROADKILL HUNDRED [3] => A [statusActual] => A [4] => BETWEEN RT. 1 & 113 [section] => BETWEEN RT. 1 & 113 [5] => DUORY CIRCLE [AddressStreetName] => DUORY CIRCLE [6] => MILTON [AddressCity] => MILTON [7] => [AddressUnitNumber] => [8] => Link to comment https://forums.phpfreaks.com/topic/163061-get-all-data-from-a-table-whatever-the-number-of-columns/#findComment-860395 Share on other sites More sharing options...
MexiTek Posted June 20, 2009 Share Posted June 20, 2009 You could try this inside your while. while ( list($key,$value) = each($e) ) { echo $key.' => '.$value; } Link to comment https://forums.phpfreaks.com/topic/163061-get-all-data-from-a-table-whatever-the-number-of-columns/#findComment-860401 Share on other sites More sharing options...
MadTechie Posted June 20, 2009 Share Posted June 20, 2009 Something like this should do it <?php $tables = array("table1", "table2","etc"); $data = array(); foreach($tables as $table) { echo "$table<br>/n"; $result = mysql_query("SELECT * FROM $table"); echo "<pre>"; while ($row = mysql_fetch_assoc($result)) { var_dump($row); //$data[$table][] = $row; //Capture data } echo "</pre>"; echo "<br>/n"; } //var_dump($data); //show all data ?> EDIT: added a capture array (commented out) Link to comment https://forums.phpfreaks.com/topic/163061-get-all-data-from-a-table-whatever-the-number-of-columns/#findComment-860406 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.