harkly
01-31-2012, 09:26 PM
I have a 2 forms that work separetly but I have them nested, from what I've read I shouldn't do this. The nested forms are working except for the format which makes the container box double in length, no matter what I do. So I am trying to do it the proper way but cannot figure out how to combine my 2nd array with the main one.
Would appreciate some help :)
This is the main form, it allows you to select messages or a message and set it to something different. Think of email but with check boxes.
<form action='' method='POST' name='myForm' id='user'>
<div id='newMsgButtons'>
<input type='submit' name='unread' value='Mark Unread' class='btn' onmouseover=\"this.className='btn btnhov'\" onmouseout=\"this.className='btn'\"> <img src='img/line.png' width='1' height='13'>
<input type='submit' name='read' value='Mark Read' class='btn' onmouseover=\"this.className='btn btnhov'\" onmouseout=\"this.className='btn'\"> <img src='img/line.png' width='1' height='13'>
<input type='submit' name='delete' value='Delete' class='btn' onmouseover=\"this.className='btn btnhov'\" onmouseout=\"this.className='btn'\">
</div>
<div id='selectAll'>Select: <a href=\"javascript:selectToggle(true, 'myForm');\">All</a>, <a href=\"javascript:selectToggle(false, 'myForm');\">None</a></div> ";
echo"<span class='checkbox'><input type='checkbox' name='answers[]' value='$id'></span>";
Once your selection has been made it kicks it to this code and process it (there is more code this is just one)
$my_array = $_POST['answers'];
// sets message to Unread status
if($_POST['unread']){
$totalIDs = count($my_array);
for ( $i=0; $i < $totalIDs; $i++ ) {
$sql2 = mysql_query("SELECT sender FROM nudges WHERE id='$my_array[$i]'");
while($r = mysql_fetch_array($sql2)) {
$sender=$r['sender'];
$query12 = ("UPDATE nudges SET r_status=0 WHERE id='$my_array[$i]'");
$result12 = mysql_query($query12) or die(mysql_error());
} // END while
} // END for
} // END if($_POST['unread'])
So now I want to take the 2nd form and be able to combine with the main form
$query7 = mysql_query("SELECT * FROM blockUser WHERE blockUserID='$clientID' AND blockID='$sender'");
$num_rows = mysql_num_rows($query7);
if ($num_rows >= 1 ) {
echo "<img src='img/delete2.png' title='Blocked'>";
}
else {
echo "
<input type='hidden' name='block2' value='$sender' />
<input type='image' value='Block' src='delete.png' title='Block'>
";
}
This is its processing code
if($_POST['block2']){
//checking to see that user is in the saved, if it is removing it
$result2 = mysql_query("SELECT * FROM saveUser WHERE userID='$clientID' AND saveID='$block_array[$i]'");
$num_rows = mysql_num_rows($result2);
// deleting from table
if ($num_rows >= 1 ) {
$query1 = "DELETE FROM saveUser WHERE userID='$clientID' AND saveID='$block_array[$i]'";
$result = mysql_query($query1) or die(mysql_error());
}
//checking to see that user is in the saved, if it is removing it
$result3 = mysql_query("SELECT * FROM blockUser WHERE blockUserID='$clientID' AND blockID='$block_array[$i]'");
$num_rows3 = mysql_num_rows($result3);
if ($num_rows3 == 0 ) {
// now inserting info to block the user from appearing
$query2 = ("INSERT INTO blockUser VALUES(NULL,'$clientID','$block_array[$i]')");
$result2 = mysql_query($query2) or die(mysql_error());
}
}
I have modified the form and the processing code for an array but cannot get anything to work.
I've been working on this all day and finally decided that I need help, if someone can point me in the right direction.
Would appreciate some help :)
This is the main form, it allows you to select messages or a message and set it to something different. Think of email but with check boxes.
<form action='' method='POST' name='myForm' id='user'>
<div id='newMsgButtons'>
<input type='submit' name='unread' value='Mark Unread' class='btn' onmouseover=\"this.className='btn btnhov'\" onmouseout=\"this.className='btn'\"> <img src='img/line.png' width='1' height='13'>
<input type='submit' name='read' value='Mark Read' class='btn' onmouseover=\"this.className='btn btnhov'\" onmouseout=\"this.className='btn'\"> <img src='img/line.png' width='1' height='13'>
<input type='submit' name='delete' value='Delete' class='btn' onmouseover=\"this.className='btn btnhov'\" onmouseout=\"this.className='btn'\">
</div>
<div id='selectAll'>Select: <a href=\"javascript:selectToggle(true, 'myForm');\">All</a>, <a href=\"javascript:selectToggle(false, 'myForm');\">None</a></div> ";
echo"<span class='checkbox'><input type='checkbox' name='answers[]' value='$id'></span>";
Once your selection has been made it kicks it to this code and process it (there is more code this is just one)
$my_array = $_POST['answers'];
// sets message to Unread status
if($_POST['unread']){
$totalIDs = count($my_array);
for ( $i=0; $i < $totalIDs; $i++ ) {
$sql2 = mysql_query("SELECT sender FROM nudges WHERE id='$my_array[$i]'");
while($r = mysql_fetch_array($sql2)) {
$sender=$r['sender'];
$query12 = ("UPDATE nudges SET r_status=0 WHERE id='$my_array[$i]'");
$result12 = mysql_query($query12) or die(mysql_error());
} // END while
} // END for
} // END if($_POST['unread'])
So now I want to take the 2nd form and be able to combine with the main form
$query7 = mysql_query("SELECT * FROM blockUser WHERE blockUserID='$clientID' AND blockID='$sender'");
$num_rows = mysql_num_rows($query7);
if ($num_rows >= 1 ) {
echo "<img src='img/delete2.png' title='Blocked'>";
}
else {
echo "
<input type='hidden' name='block2' value='$sender' />
<input type='image' value='Block' src='delete.png' title='Block'>
";
}
This is its processing code
if($_POST['block2']){
//checking to see that user is in the saved, if it is removing it
$result2 = mysql_query("SELECT * FROM saveUser WHERE userID='$clientID' AND saveID='$block_array[$i]'");
$num_rows = mysql_num_rows($result2);
// deleting from table
if ($num_rows >= 1 ) {
$query1 = "DELETE FROM saveUser WHERE userID='$clientID' AND saveID='$block_array[$i]'";
$result = mysql_query($query1) or die(mysql_error());
}
//checking to see that user is in the saved, if it is removing it
$result3 = mysql_query("SELECT * FROM blockUser WHERE blockUserID='$clientID' AND blockID='$block_array[$i]'");
$num_rows3 = mysql_num_rows($result3);
if ($num_rows3 == 0 ) {
// now inserting info to block the user from appearing
$query2 = ("INSERT INTO blockUser VALUES(NULL,'$clientID','$block_array[$i]')");
$result2 = mysql_query($query2) or die(mysql_error());
}
}
I have modified the form and the processing code for an array but cannot get anything to work.
I've been working on this all day and finally decided that I need help, if someone can point me in the right direction.