alka Posted November 29, 2010 Share Posted November 29, 2010 Hi, I have a little problem that I can't seem to solve myself. My coding skills are very limited, just wanted to mention that . I have a list of rows, bascially banners that members submit. They have to be manually approved by me before they are put on air. So to quicken up this process I made this little code in my admin panel. $bq = mysql_query("SELECT id, usrid, bname, burl, btarget FROM ban_rotator WHERE status = 'Waiting'"); $pb = mysql_num_rows($bq); if ($_GET['ap']) { $bid = $_GET['ap']; mysql_query("UPDATE ban_rotator SET status = 'Active' WHERE id = '$bid'"); It works perfectly except for one thing. It will always show the banner I just approved in addition to the remaining ones that are waiting. Any tips would be appreciated. I have to add that this code is a part of a fairly large admin panel php file. Just realized i need a bit more explanation. If I hit refresh in the browser the one I just approved will be gone. As I would like it to be after hitting Approve on the banner in question. If I just approve the second banner (after approving the first), the first will be gone from the list of waiting and the second will still show until I either hit approve on the third or hit refresh in the brower. Alka Quote Link to comment Share on other sites More sharing options...
sloth456 Posted November 29, 2010 Share Posted November 29, 2010 Well your code looks good, but I can't see how to fix this without seeing the rest of your code. Could you maybe attach the files related to the approval process. Quote Link to comment Share on other sites More sharing options...
alka Posted November 29, 2010 Author Share Posted November 29, 2010 Lets give it a new try, don't know how most of the code got cut away: $bq = mysql_query("SELECT id, usrid, bname, burl, btarget FROM ban_rotator WHERE status = 'Waiting'"); $pb = mysql_num_rows($bq); if ($_GET['ap']) { $bid = $_GET['ap']; mysql_query("UPDATE ban_rotator SET status = 'Active' WHERE id = '$bid'"); } echo "Pending Banners: $pb"; echo "<br><br>"; echo "<br><br>"; for ($i = 0; $i < mysql_num_rows($bq); $i++) { $bid = mysql_result($bq, $i, "id"); $buid = mysql_result($bq, $i, "usrid"); $bname = mysql_result($bq, $i, "bname"); $burl = mysql_result($bq, $i, "burl"); $btarget = mysql_result($bq, $i, "btarget"); $apurl = $_SERVER['PHP_SELF']."?page=".$_GET['page']."&ap=$bid"; echo "Banner ID: $bid by UserID: $buid - Banner Name: $bname"; echo "<br>"; echo "<a href="removed" target=_blank><img src=$burl border=0 width=\"468\" height=\"60\"></a>"; echo "<a href=\"$apurl\">Approve</a>"; echo "<br><br>"; } Quote Link to comment Share on other sites More sharing options...
sloth456 Posted November 29, 2010 Share Posted November 29, 2010 After much umming and ahing I think I have the solution. Do your select statement after your update statement? Like this if ($_GET['ap']) { $bid = $_GET['ap']; mysql_query("UPDATE ban_rotator SET status = 'Active' WHERE id = '$bid'"); } $bq = mysql_query("SELECT id, usrid, bname, burl, btarget FROM ban_rotator WHERE status = 'Waiting'"); $pb = mysql_num_rows($bq); I think this should work, I haven't thought it all the way through, kind of got a hunch that might be your problem though. Quote Link to comment Share on other sites More sharing options...
alka Posted November 29, 2010 Author Share Posted November 29, 2010 omg. I dunno what to say or thing, its like wtf... All this time and I couldnt detect and fix that.. Its been bothering me for months.. lol Thanks. That solved the problem . Now I'll get back to it and try adding the rest of the features.. Reject/Delete etc. Quote Link to comment Share on other sites More sharing options...
sloth456 Posted November 29, 2010 Share Posted November 29, 2010 xD Man I know that feeling all too well, glad to have helped. please click the 'topic solved button at the bottom of the page so others can see. Quote Link to comment 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.