
January 24th, 2003, 05:31 PM
|
|
5B's
|
|
Join Date: Oct 2002
Location: PC, FL
Posts: 364
Time spent in forums: 1 h 48 m 26 sec
Reputation Power: 6
|
|
|
foreach + serialize question
so I got my poll so that I can add polls,..no problem,....I can echo the serialized/unserialized data into input fields for editing
PHP Code:
<?php
$poll_answers = unserialize(stripslashes($poll['choices']));
reset($poll_answers);
foreach($poll_answers as $entry)
{
$id = $entry[0];
$choice = $entry[1];
$votes = $entry[2];
?>
<tr>
<td><strong>Answer <?php echo $entry[0]; ?></strong></td>
<td>
<input class="forminput" type="text" name="answer[]" value="<?php echo $entry[1]; ?>" /> - <?php echo $entry[2]; ?>
<input type="hidden" name="votes[]" value="<?php echo $entry[2]; ?>" />
</td>
</tr>
<?php } ?>
What I can't figure out is how to recreate the serialized array again to preserve the posts for each poll answer.
In other words, If I wanted to edit an answer and maybe change the wording,..or whatever,....and there are posts for that answer already,....how can I preserve that number and put it back into the serialized array to store in the db?
__________________
-- Jason
|