erme Posted February 22, 2010 Share Posted February 22, 2010 Is there a way of separating commas in one sql field to be used in separate php variables SQL Field: 12,204,293,998,88 PHP: $var1 = 12 $var2 = 204 $var3 = 293 $var4 = 998 $var5 = 88 I'm basically trying to get around having hundreds of SQL fields .. much prefer to have the 1 field with lots of information in. Link to comment https://forums.phpfreaks.com/topic/192929-separating-commas-in-sql-field-to-be-used-in-separate-php-variables/ Share on other sites More sharing options...
Death_Octimus Posted February 22, 2010 Share Posted February 22, 2010 Im no expert but to break that down I would try <?php //all the sql stuff $numbers = mysql_fetch_row($result); $bits = explode (",", $numbers); print_r($bits); ?> Link to comment https://forums.phpfreaks.com/topic/192929-separating-commas-in-sql-field-to-be-used-in-separate-php-variables/#findComment-1016109 Share on other sites More sharing options...
erme Posted February 22, 2010 Author Share Posted February 22, 2010 Doesn't seem to do what I need it to do. Link to comment https://forums.phpfreaks.com/topic/192929-separating-commas-in-sql-field-to-be-used-in-separate-php-variables/#findComment-1016125 Share on other sites More sharing options...
SchweppesAle Posted February 22, 2010 Share Posted February 22, 2010 Doesn't seem to do what I need it to do. assuming SQL Field is a string. ex: $sqlField = '12, 204, whatever'; $bits = explode(',' , $sqlField); $bits[0] = 12, $bits[1] = 204, etc. Link to comment https://forums.phpfreaks.com/topic/192929-separating-commas-in-sql-field-to-be-used-in-separate-php-variables/#findComment-1016129 Share on other sites More sharing options...
erme Posted February 22, 2010 Author Share Posted February 22, 2010 Perfect thanks Link to comment https://forums.phpfreaks.com/topic/192929-separating-commas-in-sql-field-to-be-used-in-separate-php-variables/#findComment-1016149 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.