Jump to content

[SOLVED] multiple values from single column


unknown1

Recommended Posts

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!!

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??

 

 

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']);

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??

 

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.

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....

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.