Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 21st, 2005, 11:52 AM
Registered User
 
Join Date: Feb 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Converting mysql arrays to strings

Hi, does anyone know how to convert mysql arrays eg(row[0]) to a string value with separators in PHP. I am trying to get email info from a database to automate a mass mail out.

Cheers

Rob
 
Old February 21st, 2005, 01:57 PM
Authorized User
 
Join Date: Jan 2005
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

assuming you are using a select statement:

$query = "Select * from sometable";
$query2 = mysql_query($query);

while ($row = mysql_fetch_array){
     foreach($row as $key=>$value){
         $string[].=$value .', ';
     }


}

----------------
Never bother to learn something not knowing which does not do you any harm, and never neglect to learn something whose negligence will increase your ignorance - Imam Jafar Sadeq
 
Old February 21st, 2005, 02:16 PM
Authorized User
 
Join Date: Jan 2005
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i just thought about this, this might be another alternative:

$query = "SELECT CONCAT(fieldname1, ', ', fieldname2,', ',fieldname3) AS fulltext FROM sometable ORDER BY fieldname1";

----------------
Never bother to learn something not knowing which does not do you any harm, and never neglect to learn something whose negligence will increase your ignorance - Imam Jafar Sadeq
 
Old February 25th, 2005, 04:11 PM
Authorized User
 
Join Date: Jan 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just use PHP function IMPLODE()

Yo





Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting Excel to Mysql Tutorial klyau23 MySQL 3 May 12th, 2007 07:56 AM
HOW TO USE STRINGS,ARRAYS AND VARIABLES IN PHP jhan316 Beginning PHP 1 July 25th, 2006 07:17 PM
sendAndLoad Arrays to MySQL harpua Flash (all versions) 1 May 11th, 2006 07:40 PM
Mysql,PHP and arrays swedge MySQL 1 February 15th, 2006 07:55 AM
Converting an XML data island to 2 arrays NeilAtWork Classic ASP XML 0 April 14th, 2004 10:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.