Attribute Select Max Characters

Permalink
I'm using a select attribute to store sentences that are then looped over to output a ul li.

My problem is that after so many characters, I get an SQL error, saying its too long.
sqlstate 22001 string data right truncated 1406 data too long for column

ob7dev
 
WillemAnchor replied on at Permalink Reply
WillemAnchor
ok, it's too long

Post some code and info plz
A3020 replied on at Permalink Best Answer Reply
A3020
Yeah, Willem is right. The text is too long to fit in the select option value column. The max length is set to 255 chars in the database. You can of course change the column type to a TEXT for example, but I wouldn't recommend it.

Maybe you can use a textfield attribute or something where you explode (see PHP manual) on a line break or some special character?
ob7dev replied on at Permalink Reply
ob7dev
Thank you for the suggestion, my solution was by following your instructions:
First grab the text field containing each item on its own line:
$details = $c->getAttribute('text_area');

Then explode the text area by line break:
$list = explode("\n", $details);

Then loop over each item in the newly created list array and output in an li:
<ul>
<? foreach ($list as $list_item):?>
<li>
<?=$list_item?>
</li>
<?endforeach?>
</ul>