I have a script where I am extracting content from a field in a mysql db and exploding it by a custom tag and getting an array. Then I print out the results in a new form so that I can reorder the contents.
The project is a survey system and I need to be able to have the users reorder the answers they have already submitted. I've gotten as far as writing the code to display the form but need to know how to retrieve the data from this form in order to process it and rebuild it in the new order to go back into the database.
Here the code so far (the essential code)
<?php
// Find the answers for this question already in database.
$findq = $_POST['findq'];
$pullquery = "SELECT answers FROM questions WHERE quid = '$findq'";
$pullresult = mysql_query ($pullquery);
$serverself = $_SERVER['PHP_SELF'];
echo "<form enctype='multipart/form-data' action='$serverself' method='post'>";
if (mysql_num_rows($pullresult) > 0 )
{
while ($pullv = mysql_fetch_array($pullresult))
{
$pullanswers = $pullv['answers'];
$pullanswers = explode('<znxt>',$pullanswers);
$countanswers = count($pullanswers);
for ( $i = 1; $i <= $countanswers; $i++)
{
$iindex = $i-1;
echo "<div style='margin-bottom: 5px;'><input name='reordervalue[$i]' type='text' value='$i' size='1'>";
echo " <input name='$pullanswers[$iindex]' type='text' value='$pullanswers[$iindex]' readonly='true'> [ <a href='#'>Delete</a> ]</div>";
}
}
}
echo "<br><input type='hidden' name='quid' value='$quid'><input name='reorder' type='submit' value='Re Order'></form><br><br>";
?>