Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 21st, 2005, 11:52 AM
Registered User
 
Join Date: Feb 2005
Location: , , .
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
Reply With Quote
  #2 (permalink)  
Old February 21st, 2005, 01:57 PM
Authorized User
 
Join Date: Jan 2005
Location: , , .
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
Reply With Quote
  #3 (permalink)  
Old February 21st, 2005, 02:16 PM
Authorized User
 
Join Date: Jan 2005
Location: , , .
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
Reply With Quote
  #4 (permalink)  
Old February 25th, 2005, 04:11 PM
Authorized User
 
Join Date: Jan 2005
Location: Siemianowice, , Poland.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just use PHP function IMPLODE()

Yo
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 05:34 AM.


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