The question might seem a little odd but I will show you what I mean :)
So I have made a webpage that contains comments that have been made by authorised users (teachers). That is another piece of code in another page so that works perfectly. Of course it should be possible for the person who made the comment to change his own comments in case of mistakes etc.
I managed to show the user his own comments with his comments in seperate text areas. The text areas have no specific name and are just called txtComment, how do I make them unique for every comment (which is flexible because comments can be added later). I think that is the issue why I cannot update the changed/adapted textareas after I press the button.
I hope you guys understand what I am trying to say :p
I changed Dutch words mostly to English so if there is a spelling error that is due to that :)
This is the code:
<?php
$sqlKlas = "Select * from tblcomments WHERE ForWho='".$_SESSION['User']."' AND ForWho='6HA1' OR VoorWie='6HA2'";
$resultKlas = mysql_query($sqlKlas) or die(mysql_error());
if (isset($_POST['btnAdaptCommentKlas'])){
while($rowKlas = mysql_fetch_array($resultKlas)){
$CommentNr = $rowKlas['CommentNr'];
$sqlUpdate = "Update tblcomments SET Comment='".$_POST['txtComment']."' WHERE CommentNr=$CommentNr";
$resultUpdate = mysql_query($sqlUpdate) or die(mysql_error());
echo "<tr>";
echo "<td>";
?><textarea name="txtComment" cols="80" rows="5"><?php echo $rowKlas['Comment']; ?></textarea><?php
echo "</td>";
echo "<td>".$rowKlas['ForWho']."</td>";
echo "<td>".$rowKlas['Datum']."</td>";
echo "</tr>";
}
}
else {
while($rowKlas = mysql_fetch_array($resultKlas)){
echo "<tr>";
echo "<td>";
?><textarea name="txtComment" cols="80" rows="5"><?php echo $rowKlas['Comment']; ?></textarea><?php
echo "</td>";
echo "<td>".$rowKlas['ForWho']."</td>";
echo "<td>".$rowKlas['Datum']."</td>";
echo "</tr>";
}
}