Jump to content

Changine one row in mysql and listing them (in lack of better description lol)


alka

Recommended Posts

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  :P.

 

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

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>";
	}

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.

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.