RE: Formatting MySQL Queries
| From: | Jeremy Glover | Date: | Wed, 24 Jan 2007 21:46:38 +0000 |
| Subject: | RE: Formatting MySQL Queries | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-42967@lists.php.net to get a copy of this message | ||
<?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@gmail.com]
Sent: Wednesday, January 24, 2007 4:21 PM
To: php-db@lists.php.net
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@trone.com
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.