jaredclance Posted October 22, 2007 Share Posted October 22, 2007 Okay so thanks to only one for helping me with the last problem. Now I have a drop down box, I select a user, hit approve and it updates their status in the database and SHOULD remove their name from the drop down box. If I refresh the page a 2nd time after I click on the submit button, or if I approve another user, it will remove their name. But it always takes 2 page refreshes to remove their name. How can I make it so after I hit the approve button, their name is removed from the drop down list? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/74349-solved-page-refresh/ Share on other sites More sharing options...
pocobueno1388 Posted October 22, 2007 Share Posted October 22, 2007 You need to post the code that does the updating BEFORE you do the HTML for the drop-down. Could you post your code? Quote Link to comment https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-375652 Share on other sites More sharing options...
otuatail Posted October 22, 2007 Share Posted October 22, 2007 What you should do is create a pure php page with no http content. direct to it. change a field in your DB [Aproved]. then re-direct back to the original page. If you state in your SQL where approved = NO or something like that it will work. Desmond. Quote Link to comment https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-375657 Share on other sites More sharing options...
jaredclance Posted October 22, 2007 Author Share Posted October 22, 2007 Here is the code <form method="post" action="member.php"> <? echo "<select name=\"NickName\">"; echo "<option size =30 selected>Select</option>"; if(mysql_num_rows($approvalQuery)) { while($myrow = mysql_fetch_assoc($approvalQuery)) { echo "<option>$myrow[NickName]</option>"; } } else { echo "<option>No Names Present</option>"; } ?> </td> </tr> </td> <td valign="top" align="left" class="control_panel_td_2"> <input type="submit" value="Approve" name="Approve"> <input type="submit" value="Deny" name="Deny"> </form> </td> <? } ?> </tr> <? //Approves user account activation if(isset($_POST['Approve'])) { mysql_query("UPDATE Profiles SET Status = 'Active' WHERE Status='Approval' AND NickName = '{$_POST['NickName']}'") or die (mysql_error()); } Quote Link to comment https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-375714 Share on other sites More sharing options...
otuatail Posted October 22, 2007 Share Posted October 22, 2007 You have not got a vaue for the option This .... <option>$myrow[NickName]</option>; should look like <select name="NickName">; <option value="1">$myrow[NickName]</option>; // where value is the unigue ID in the database table. then on the PHP (only) update table UPDATE table SET Aproved = "Y" WHERE ID=1 Quote Link to comment https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-375720 Share on other sites More sharing options...
otuatail Posted October 22, 2007 Share Posted October 22, 2007 Sorry what I ment to say was <option value="<?=$myrow[iD]?>"><?=$myrow[NickName]?></option>; where $myrow[iD] = the unique I in the table Quote Link to comment https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-375722 Share on other sites More sharing options...
jaredclance Posted October 22, 2007 Author Share Posted October 22, 2007 It all works already, everything is posting and so on exactly how I want it to. It's just the thing doesn't refresh after the first button submit. It takes a 2nd button click, or for me to hit refresh for it to remove their name from the list. Quote Link to comment https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-375724 Share on other sites More sharing options...
marcus Posted October 22, 2007 Share Posted October 22, 2007 You have not got a vaue for the option This .... <option>$myrow[NickName]</option>; Actually the indefinite value for an option is defined within itself. So the value of <option>$myrow[Nickname]</option> is whatever $myrow[Nickname] is defined to. Quote Link to comment https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-375730 Share on other sites More sharing options...
otuatail Posted October 22, 2007 Share Posted October 22, 2007 There is code missing <form method="post" action="member.php"> No </form> as for AND NickName = '{$_POST['NickName']}'") $_POST['NickName'] YOU have not put any value to this. If this is working then you have some invisible code <OPTON Value="X">Name</Option> without the X it can't work. Quote Link to comment https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-375736 Share on other sites More sharing options...
otuatail Posted October 22, 2007 Share Posted October 22, 2007 Ok so that means that nicknmae is unique and can't exsist anywhere else. A recordse ID is still the best and it can be recovered from the table with the nickname. Quote Link to comment https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-375738 Share on other sites More sharing options...
jaredclance Posted October 22, 2007 Author Share Posted October 22, 2007 Yeah I didn't post all of the queries and stuff. I just wanna know why it takes 2 refreshes Quote Link to comment https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-375749 Share on other sites More sharing options...
marcus Posted October 22, 2007 Share Posted October 22, 2007 There is code missing <form method="post" action="member.php"> No </form> as for AND NickName = '{$_POST['NickName']}'") $_POST['NickName'] YOU have not put any value to this. If this is working then you have some invisible code <OPTON Value="X">Name</Option> without the X it can't work. Without the X it can work. <option>x</option> the value of that is x <option value="x">hello</option> the value of that is x <option>Name</option> the value of that is Name Quote Link to comment https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-375760 Share on other sites More sharing options...
jaredclance Posted October 22, 2007 Author Share Posted October 22, 2007 It all works perfectly. The page just needs 2 refreshes to remove someones name from the drop down. Quote Link to comment https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-375763 Share on other sites More sharing options...
otuatail Posted October 22, 2007 Share Posted October 22, 2007 Ok then. withot full code can't help. I just use the aproved way of database programming. If you have supplied all relivent code then you have a hardware problem. love to know what would happen if 2 or more people had the same nickname. Quote Link to comment https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-375767 Share on other sites More sharing options...
jaredclance Posted October 22, 2007 Author Share Posted October 22, 2007 Two or more people can't have the same nickname. You don't really need to know much more than this. //Grabs users awaiting Approval from the database - FINDME $approvalQuery = mysql_query("SELECT ID, NickName, Coach_Name, Email FROM `Profiles` WHERE Status='Approval' AND `Coach_Name`='{$p_arr['Coach_Name']}'"); $nameQuery = mysql_query("SELECT Coach_Name, NickName, Status FROM `Profiles` WHERE `ID`='{$p_arr['ID']}'"); $arrName = mysql_fetch_assoc( $nameQuery ); ?> </td> </tr> <? if ($arrName["Coach_Name"] == $arrName["NickName"]){ ?> <tr> <td>Approvals: </td> <td> <form method="post" action="member.php"> <? echo "<select name=\"NickName\">"; echo "<option size =30 selected>Select</option>"; if(mysql_num_rows($approvalQuery)) { while($myrow = mysql_fetch_assoc($approvalQuery)) { echo "<option>$myrow[NickName]</option>"; } } else { echo "<option>No Names Present</option>"; } ?> </td> </tr> </td> <td valign="top" align="left" class="control_panel_td_2"> <input type="submit" value="Approve" name="Approve"> <input type="submit" value="Deny" name="Deny"> </form> </td> <? } ?> </tr> <? //Approves user account activation if(isset($_POST['Approve'])) { mysql_query("UPDATE Profiles SET Status = 'Active' WHERE Status='Approval' AND NickName = '{$_POST['NickName']}'") or die (mysql_error()); } //Denies user account activation if(isset($_POST['Deny'])) { mysql_query("UPDATE Profiles SET Status = 'Rejected' WHERE Status='Approval' AND NickName = '{$approvalQuery['NickName']}'") or die (mysql_error()); } Quote Link to comment https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-375773 Share on other sites More sharing options...
pocobueno1388 Posted October 22, 2007 Share Posted October 22, 2007 Try this <?php //Grabs users awaiting Approval from the database - FINDME $approvalQuery = mysql_query("SELECT ID, NickName, Coach_Name, Email FROM `Profiles` WHERE Status='Approval' AND `Coach_Name`='{$p_arr['Coach_Name']}'"); $nameQuery = mysql_query("SELECT Coach_Name, NickName, Status FROM `Profiles` WHERE `ID`='{$p_arr['ID']}'"); $arrName = mysql_fetch_assoc($nameQuery ); //Approves user account activation if (isset($_POST['Approve'])) { mysql_query("UPDATE Profiles SET Status = 'Active' WHERE Status='Approval' AND NickName = '{$_POST['NickName']}'") or die(mysql_error()); } //Denies user account activation if (isset($_POST['Deny'])) { mysql_query("UPDATE Profiles SET Status = 'Rejected' WHERE Status='Approval' AND NickName = '{$approvalQuery['NickName']}'") or die(mysql_error()); } ?> </td> </tr> <? if ($arrName["Coach_Name"] == $arrName["NickName"]) { ?> <tr> <td>Approvals: </td> <td> <form method="post" action="member.php"> <? echo "<select name=\"NickName\">"; echo "<option size =30 selected>Select</option>"; if (mysql_num_rows($approvalQuery)) { while ($myrow = mysql_fetch_assoc($approvalQuery)) { echo "<option>$myrow[NickName]</option>"; } } else { echo "<option>No Names Present</option>"; } ?> </td> </tr> </td> <td valign="top" align="left" class="control_panel_td_2"> <input type="submit" value="Approve" name="Approve"> <input type="submit" value="Deny" name="Deny"> </form> </td> <? } ?> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-375810 Share on other sites More sharing options...
jaredclance Posted October 23, 2007 Author Share Posted October 23, 2007 Hey, I tried that, I still get the same problem. The page still needs to refresh twice before someones name is removed from the drop down. Quote Link to comment https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-376327 Share on other sites More sharing options...
pocobueno1388 Posted October 23, 2007 Share Posted October 23, 2007 Oops, try this <?php //Approves user account activation if (isset($_POST['Approve'])) { mysql_query("UPDATE Profiles SET Status = 'Active' WHERE Status='Approval' AND NickName = '{$_POST['NickName']}'") or die(mysql_error()); } //Denies user account activation if (isset($_POST['Deny'])) { mysql_query("UPDATE Profiles SET Status = 'Rejected' WHERE Status='Approval' AND NickName = '{$approvalQuery['NickName']}'") or die(mysql_error()); } //Grabs users awaiting Approval from the database - FINDME $approvalQuery = mysql_query("SELECT ID, NickName, Coach_Name, Email FROM `Profiles` WHERE Status='Approval' AND `Coach_Name`='{$p_arr['Coach_Name']}'"); $nameQuery = mysql_query("SELECT Coach_Name, NickName, Status FROM `Profiles` WHERE `ID`='{$p_arr['ID']}'"); $arrName = mysql_fetch_assoc($nameQuery ); ?> </td> </tr> <? if ($arrName["Coach_Name"] == $arrName["NickName"]) { ?> <tr> <td>Approvals: </td> <td> <form method="post" action="member.php"> <? echo "<select name=\"NickName\">"; echo "<option size =30 selected>Select</option>"; if (mysql_num_rows($approvalQuery)) { while ($myrow = mysql_fetch_assoc($approvalQuery)) { echo "<option>$myrow[NickName]</option>"; } } else { echo "<option>No Names Present</option>"; } ?> </td> </tr> </td> <td valign="top" align="left" class="control_panel_td_2"> <input type="submit" value="Approve" name="Approve"> <input type="submit" value="Deny" name="Deny"> </form> </td> <? } ?> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-376337 Share on other sites More sharing options...
otuatail Posted October 23, 2007 Share Posted October 23, 2007 I gave you a tried and tested solution to this. If you choose to ignore it then ... Quote Link to comment https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-376340 Share on other sites More sharing options...
jaredclance Posted October 23, 2007 Author Share Posted October 23, 2007 It doesn't approve if I redirect it to a blank PHP page Quote Link to comment https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-376343 Share on other sites More sharing options...
jaredclance Posted October 23, 2007 Author Share Posted October 23, 2007 Thanks pocobueno1388, worked like a charm. Quote Link to comment https://forums.phpfreaks.com/topic/74349-solved-page-refresh/#findComment-376344 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.