note 56687 deleted from function.mysql-fetch-field by danbrown

From: Date: Sat, 20 Jun 2009 02:15:20 +0000
Subject: note 56687 deleted from function.mysql-fetch-field by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-157158@lists.php.net to get a copy of this message
Note Submitter: admin at str-atm dot com ---- If you need to get separated field size you should use this part of code (I also included a database request function): !!!!! Take care of warped lines ---------------- // Function to call to perform a database request <? function sql_request($sql_query,$db_name) { global $rows_count; $db_link = mysql_connect("localhost","username","password") or die("MySQL connect failed"); @mysql_select_db($db_name) or die("unable to select: $db_name"); $query_answer = mysql_query($sql_query); $rows_count = mysql_num_rows($query_answer); mysql_close($db_link); return $query_answer; } $editing_db = "mydb"; $editing_table = "mytable"; $query_answer = sql_request("SHOW FIELDS FROM $editing_table",$editing_db); $i = 0; while ($row = mysql_fetch_array($query_answer)) { $table_structure[$i][0] = $row['Field']; $first_parenthesis = strpos($row['Type'],"("); $last_parenthesis = strpos($row['Type'],")"); if ($first_parenthesis AND $last_parenthesis) { $table_structure[$i][1] = substr($row['Type'],0,$first_parenthesis); $table_structure[$i][2] = substr($row['Type'],$first_parenthesis+1, $last_parenthesis-$first_parenthesis-1); } if ($row[Key] == "PRI") $table_structure[$i][3] = 1; echo $i." ".$table_structure[$i][0]." "; echo $table_structure[$i][1]." "; echo $table_structure[$i][2]." ".$table_structure[$i][3]."<br>"; $i++; } ?> Hope this will be usefull! Andre Lebeuf STR ATM and Terminals

« previous php.notes (#157158) next »