all fields or specific from all talbes of given database

Posted: April 3, 2010 in PHP Stuff
Tags:

$sql = “show tables”;
$query = mysql_query($sql);
echo “

";
		
	  while($arr = mysql_fetch_array($query))
	  {	
			$key = $arr[0];
  		$sql1 = "SELECT * FROM $key";
			$query1 = mysql_query($sql1);
			if($query1)
			{
				$columns1 = mysql_num_fields($query1);
			

				for($i1 = 0; $i1 < $columns1; $i1++) 
				{
	  			//$arra[$key][] = mysql_field_name($query1,$i1);
					  $fieldStr = mysql_field_name($query1,$i1);  			
					  if(strstr($fieldStr, 'dep'))
					  {
			  			$arra[$key][] = $fieldStr;
						}
				} 
			}
		}
		print_r	($arra);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s