Okay so here is my dilemma. I am trying to write a PHP script that is going to add and delete and edit comments.
As of now it adds comments fine. Here is the problem. When I try to delete.This is how I have my DB calls set up and stuff set up for the deletion:
$query = “MYQUERY”
$result = mysql_query($query) or die(“Unable to retrieve comments.”);
$num = mysql_numrows($result);
$i=0;
while ($i < $num)
{
$id = mysql_result($result);
$vid_id = mysql_result($result);
$comment = mysql_result($result);
$user = mysql_result($result);
$date = mysql_result($result);
$totalComments = $num;
echo ‘<b style=”color:#0DB20D;”>’,$user, ‘</b><b style=”color:#ff9002;”> – ‘,$date,’ </b>
<div class=”fixComments”>
<!— this is for deletion of comments —>
<form action=”delete” method=”GET” style=”display: inline;”>
<!– these are hidden variables that need to get passed –>
<input type=”text” name=”vidId” value=”‘, $vid_id, ‘” style=”display:none;” />
<input type=”text” name=”id” value=”‘, $id,'” style=”display:none;” />
<!– end hidden fields –>
<input type=”submit” name=”uname” value=”Delete” style=”color:#FF0000;font-size: 8pt; font-family:Calibri; cursorointer;background:transparent;border:0;”/>
</form>
</div>
So basically the logic is I was thinking I could store the vidId and Id for every one that I printed out. That way when they clicked ‘delete’ button it will be able to pull that comment from the database and show a confirm page before it deletes it.
However because every form has the same variable name, all the variables end up being set to the most recent pull from the database, so only the most recent pull can be deleted at this point.
Any ideas? Thanks.
-webDevShane