note 94064 added to book.mssql

From: Date: Wed, 14 Oct 2009 20:35:12 +0000
Subject: note 94064 added to book.mssql
Groups: php.notes 
Request: Send a blank email to php-notes+get-161737@lists.php.net to get a copy of this message
CORRECTION FOR exidas at madnes dot eu (The original script wasn't maintaining the columns returned with their related table.) <?php $all = MSSQL_Query("select TABLE_NAME, COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS order by TABLE_NAME, ORDINAL_POSITION"); // Check if there were any records found if(!mssql_num_rows($all)) { echo 'No records found'; } else { $tables = array(); $columns = array(); while($fet_tbl = MSSQL_Fetch_Assoc($all)) { // PUSH ALL TABLES AND COLUMNS INTO THE ARRAY $tables[] = $fet_tbl[TABLE_NAME]; $columns[$fet_tbl[TABLE_NAME]][] = $fet_tbl[COLUMN_NAME]; } $sltml = array_count_values($tables); // HOW MANY COLUMNS ARE IN THE TABLE foreach($sltml as $table_name => $id) { echo "<h2>". $table_name ." (". $id .")</h2><ol>"; for($i = 0; $i <= $id-1; $i++) { echo "<li>". $columns[$table_name][$i] ."</li>"; } echo"</ol>"; } } // Free the query result mssql_free_result($all); ?> ---- Server IP: 192.41.40.227 Probable Submitter: 209.244.4.106 ---- Manual Page -- http://www.php.net/manual/en/book.mssql.php Edit -- https://master.php.net/note/edit/94064 Del: integrated -- https://master.php.net/note/delete/94064/integrated Del: useless -- https://master.php.net/note/delete/94064/useless Del: bad code -- https://master.php.net/note/delete/94064/bad+code Del: spam -- https://master.php.net/note/delete/94064/spam Del: non-english -- https://master.php.net/note/delete/94064/non-english Del: in docs -- https://master.php.net/note/delete/94064/in+docs Del: other reasons-- https://master.php.net/note/delete/94064 Reject -- https://master.php.net/note/reject/94064 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#161737) next »