Jump to content

form obtaining values for process


thefollower

Recommended Posts

I have a form which has a while loop inside to echo a table. But not only that i have a submit button and a check box which I want to have the value of the row's ID so that if the submit button is pressed it will delete the adjacent row.. but just curious if this following idea is going to work :

 

Form:

<form name="" method="POST" action="deletemessages.php"   id="Form1" onsubmit="return ValidateForm1(this)">


<?
$Total = 0;
$Distance = 60;
while($row = mysql_fetch_array($GetLetters)) {
$Total = $Total + 1;
$Distance = $Distance + 60;
$Subject = $row['Subject'];
$From = $row['Sender'];
$SentOn = $row['SentTime'];
$Message = $row['MessageText'];
$MessageID = $row['CallID'];
$FindUser = mysql_query("SELECT * FROM userregistration WHERE UserID='$From'") or die(mysql_error());
//Fetch the row from the database
if (mysql_num_rows($FindUser)) {
  $rowuser = mysql_fetch_assoc($FindUser);
  $UserName = $rowuser['Username'];
  $StaffMember = $rowuser['StaffDuties'];
}
If ($StaffMember == ''){
$Staff = '';
}
Else{
$Staff = 'STAFF MEMBER';
}


echo '<tr>
    <td width="200"><center><font style="font-size:14px" color="#FFFFFF" face="Arial">From: <font color="#32CD32">'; 
Echo $UserName; 
Echo'</font></br><font color="#EE9A4D">'; 
Echo $Staff; 
Echo'</font>';
Echo'</br><font color="#FFFFFF">Sent On: </font><font color="#32CD32">'; 
Echo $SentOn; 
Echo'</font></br></center></font></td>
    <td width="200"><center><font style="font-size:14px" color="#FFFFFF" face="Arial">Subject: </font></br><font color="#32CD32">'; 
Echo $Subject; 
Echo'</br><hr size="2" width="40" id="Line2" style="width:200px;height:2px;z-index:0">';
Echo'</font>'; 
Echo'<font color="#FFFFFF">Message: </font><font color="#32CD32"></br><b>'; 
Echo $Message; 
Echo'</font></b></center></font></td>';

Echo'
<td background="menu_gradient.gif" bgcolor="#FFFFFF" style="background-repeat: repeat-x;"><center><font style="font-size:14px" color="#FFFFFF" face="Arial">';
Echo'<a href="reportmessage.php?report=';Echo$MessageID;Echo'">Report</a></br></br>';
Echo'<input type="checkbox" id="Checkbox1" name="';Echo$MessageID;Echo'" value="">
<input type="submit" id="Button1" name="';Echo$MessageID;Echo'" value="Delete">';
Echo'</center></td></tr>';
}
echo '</br></br></table></br></div>';
?>
</form>

 

Then i was going to put in the deletemessages.php from the forms action option to do a $_POST['ButtonName'];

But i am not sure what i should put in the ['ButtonName'] part in bold... cos $MessageID isnt a session and it can be if its a while loop cos itll only every be the last row that is assigned to the session... so how can i get the submit (and the checkbox) to be related to each row correct and then in the form obtain the correct row value which in this situation is ID.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.