Man this php stuff is a bitch...seems like it works, then it doesn't. Ok I gave up, for now, on the whole displaying banners in rows idea, will come back to that. I feel that I should have to approve submitted banners before they appear, so I've created an extra field in my database - approved, with a default of 0. My affiliate page is set to display only those with an approved state of 1, and this works fine. My affiliate admin page, is set to display those that aren't approved, with two links - "Approve" or "Delete." now my code, which I think is correct, doesn't work. tres surprise. however, the query success message is echoed..just nothing happens. Thoughts? PHP: <?php$query="SELECT * from affiliates where approved = 0";$result=mysql_query($query) or die ("Couldn't execute query: $query." . mysql_error());while($row=mysql_fetch_array($result)){extract($row); // extract row values?><table width="300" cellpadding="2" cellspacing="5" border="1" bordercolor="#700909" style="border-collapse:collapse "><tr><td width="100"> <div align="center"><img src="<?php echo $banner; ?>" border="0"> </div></td><td><b>Site:</b> <?php echo "<a href=\"$url\" target=\"_blank\">$url"?><br><br><center><a href="?module=admin&action=manageaffiliates&approve=yes&id=<?php echo $id; ?>">Approve</a> //this is the bit i think is wrong...</center></td></tr></table><br><?php} // end of whileif($_GET[approve] == yes) //or this.{$sql = mysql_query("'UPDATE `affiliates` SET `approved` = '1' WHERE `id` = $id LIMIT 1'");echo("Approved!");}?>
simple where have you got the $banner $url and $id variables from? I think you will need to use $row[1] $row[2] etc depending on how its stored in the DB.
sorry..clarify that? Like instead of using the unique $id, use the row number?? surely thats the same thing.
in the affiliates table, there are the following fields (id being the automatic increment and primary key) id url banner approved so when the $id is pulled up, it echoes out the url and banner attached to it.
thats fine but you have to assign the results to the $id so it would be something like after the while($row=mysql_fetch_array($result)) { $id = $row['id']; then it should work. I assume you are using extract to do the samething, since I'm not sure how it works?
ahh that could well be it. I was talking with a lecturer at college about it and he suggested I tried the extract() method I'll try that later..thanks man
Ok didn't seem to change a thing... now the part that is problematic. The Approve link is: PHP: <a href=\"?module=admin&action=manageaffiliates&approve=yes&id=$id\">Approve</a> which displays fine, for each affiliate banner, there is a link saying "Approve", and the link contains this, for example: PHP: <a href=\"?module=admin&action=manageaffiliates&approve=yes&id=2\">Approve</a> This would approve banner with $id 2. This is the part I have wrong. PHP: <?phpif($_GET[approve=yes&id] == $id) // right here..I don't know how to word it so it checks to see if approve was clicked, and what ID to approve it was. Hope this is making sense..{$sql = mysql_query("'UPDATE `affiliates` SET `approved` = '1' WHERE `id` = $id LIMIT 1'");mysql_query($query);echo("Approved!");}?>
this might work PHP: <?if (@$approve== 'yes') {$id = $_GET['id'];$sql = mysql_query("'UPDATE `affiliates` SET `approved` = '1' WHERE `id` = $id LIMIT 1'");mysql_query($query);echo("Approved!");}?>
Figured it out, thanks for the help though. PHP: <? if($_GET["approve"]=="yes") { $id = $_GET['id']; $sql = "UPDATE affiliates SET approved='1' WHERE id=$id"; $result = mysql_query($sql); echo "Approved."; } ?>