unknown1 Posted November 7, 2009 Share Posted November 7, 2009 Hello all, I created a script that stores multiple values in a single mysql column and I'm trying to echo each out without the values being separated by a comma and or having to go $v[0] $v[1].... can someone explain how I can echo each value of the column out on a new line. $value = explode(",",$row['some_value']); but it just says array when I echo it out... Thanks in advance!! Quote Link to comment https://forums.phpfreaks.com/topic/180699-solved-multiple-values-from-single-column/ Share on other sites More sharing options...
unknown1 Posted November 7, 2009 Author Share Posted November 7, 2009 Hello all, I created a script that stores multiple values in a single mysql column and I'm trying to echo each out without the values being separated by a comma and or having to go $v[0] $v[1].... can someone explain how I can echo each value of the column out on a new line. $value = explode(",",$row['some_value']); but it just says array when I echo it out... Thanks in advance!! Not 100% sure if that's even right... should I even be treating the values of the column as an array or am I just trying to format the values after.... what id the best way to go about this?? Quote Link to comment https://forums.phpfreaks.com/topic/180699-solved-multiple-values-from-single-column/#findComment-953365 Share on other sites More sharing options...
Alex Posted November 7, 2009 Share Posted November 7, 2009 Having to store values like this in mysql is usually a sign of poor database design, that being said.. The reason why you're getting 'Array' is because explode() returns an Array. If all you want to do is to echo out all the values separated by a space instead of a comma, why don't you just do: echo str_replace(',', ' ', $row['some_value']); Quote Link to comment https://forums.phpfreaks.com/topic/180699-solved-multiple-values-from-single-column/#findComment-953366 Share on other sites More sharing options...
unknown1 Posted November 7, 2009 Author Share Posted November 7, 2009 Having to store values like this in mysql is usually a sign of poor database design, that being said.. The reason why you're getting 'Array' is because explode() returns an Array. If all you want to do is to echo out all the values separated by a space instead of a comma, why don't you just do: echo str_replace(',', ' ', $row['some_value']); Should I not be treating the column as an array?? If not why?? Would exploding the values not do the same thing? I am just trying to separate each value onto a new line... and I guess I could just go echo str_replace(',', ' \n', $row['some_value']); or would that work?? Quote Link to comment https://forums.phpfreaks.com/topic/180699-solved-multiple-values-from-single-column/#findComment-953368 Share on other sites More sharing options...
unknown1 Posted November 7, 2009 Author Share Posted November 7, 2009 Having to store values like this in mysql is usually a sign of poor database design, that being said.. The reason why you're getting 'Array' is because explode() returns an Array. If all you want to do is to echo out all the values separated by a space instead of a comma, why don't you just do: echo str_replace(',', ' ', $row['some_value']); Should I not be treating the column as an array?? If not why?? Would exploding the values not do the same thing? I am just trying to separate each value onto a new line... and I guess I could just go echo str_replace(',', ' <br>', $row['some_value']); or would that work?? The reason I ask if I can somehow treat the values in the column as an array is because I also need to compare each value to other values in another table row in the database... so I would need be checking them one value at a time. Quote Link to comment https://forums.phpfreaks.com/topic/180699-solved-multiple-values-from-single-column/#findComment-953369 Share on other sites More sharing options...
unknown1 Posted November 7, 2009 Author Share Posted November 7, 2009 BTW I did it like this because it's an invite script that saves the emails invited to the database in one column... the reason for this is because the invite sends mass emails and it stores multiple emails to that one single column. Then I want to do a check on another table row to see what emails are ones that have actually signed up.... Quote Link to comment https://forums.phpfreaks.com/topic/180699-solved-multiple-values-from-single-column/#findComment-953373 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.