RE: Formatting MySQL Queries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



<?php
	// Make sure you're already connected to the database...
	
	function return_mysql_table($table_name, $id_column)
	{
		$sql = "SELECT * FROM " . $table_name . " ORDER BY " .
$id_column . " ASC";
		$result = mysql_query($sql) or die("Error: Invalid SQL:
" . $sql);
		
		$rows = array();
		
		while($current_row = mysql_fetch_array($result))
		{
			$rows[] = implode("\t", $current_row);
		}
		
		$table = implode("\r\n", $rows);
		
		return $table;
	}
?> 

-----Original Message-----
From: Brent Anderson [mailto:brentj84062@xxxxxxxxx] 
Sent: Wednesday, January 24, 2007 4:21 PM
To: php-db@xxxxxxxxxxxxx
Subject: Formatting MySQL Queries

Hello.

My team and I are looking for a way to return an entire table of MySQL
data with columns delimited by tabs and rows delimited by carriage
returns. How exactly would this work - I'm not a PHP expert and,
although I know MySQL, I don't know where to begin with formatting a
query pointer into an actual pile of text. We have an engine ready to
take tables in this format for processing, we just need to parse the
query data into a text result.

Thanks,
Brent Anderson

~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jeremy Glover
Interactive Communication Developer, Trone
336.819.6934
jglover@xxxxxxxxx


Confidentiality Notice: This e-mail communication and any attachments may contain confidential and privileged information for the use of the designated recipients named above.  If you are not the intended recipient, you are hereby notified that you have received this communication in error and that any review, disclosure, dissemination, distribution or copying of it or its contents is prohibited.  If you have received this communication in error, please notify me immediately by replying to this message and deleting it from your computer.  Thank you.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux