piznac Posted September 20, 2006 Share Posted September 20, 2006 Ok,.. I would have thought this would have been simple,.. but I can't seem to pull it off. I have a list of email addys store in a table and I need to pull those results. Then place them as a comma seperated string in a variable. Here is what I have so far:[code]<?php mysql_select_db($database_pms, $pms);$query = sprintf("SELECT email FROM access");$em = mysql_query($query) or die(mysql_error());$array = array($em);$comma_separated = implode(",", $array);echo $comma_separated;?>[/code]this is simply returning: Resource id #4 I had it set up like this:[code]<?php mysql_select_db($database_pms, $pms);$query = sprintf("SELECT email FROM access");$em = mysql_query($query) or die(mysql_error());while ($array= mysql_fetch_assoc($em)) { $try2 = "$array[email]\n"; $try3 = explode(" ",$try2); echo $try3[0]; $fnamec=str_replace(' ', ',', $try3[0]); echo $fnamec; }?>[/code]I can get it to display the array,.. but not comma seperated and not where I can use it Quote Link to comment https://forums.phpfreaks.com/topic/21398-cs-array-from-mysql-results/ Share on other sites More sharing options...
ober Posted September 20, 2006 Share Posted September 20, 2006 [code]<?php mysql_select_db($database_pms, $pms);$query = sprintf("SELECT email FROM access");$em = mysql_query($query) or die(mysql_error());$myarray = array();while($row = mysql_fetch_array($em)) $myarray[] = $row['email'];$comma_seperated = implode(",", $myarray);echo $comma_separated;?>[/code]Kind of a mixture of the two that you had. Quote Link to comment https://forums.phpfreaks.com/topic/21398-cs-array-from-mysql-results/#findComment-95298 Share on other sites More sharing options...
piznac Posted September 20, 2006 Author Share Posted September 20, 2006 hmm,.. Im getting no results returned with this :-\ Quote Link to comment https://forums.phpfreaks.com/topic/21398-cs-array-from-mysql-results/#findComment-95302 Share on other sites More sharing options...
piznac Posted September 20, 2006 Author Share Posted September 20, 2006 ahhh it would appear the variable was misspelled,. thanks for the help man!!:) Quote Link to comment https://forums.phpfreaks.com/topic/21398-cs-array-from-mysql-results/#findComment-95320 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.