Jump to content

Updating specific rows


lJesterl

Recommended Posts

Hi guys i always come here for help and you all have always helped me. This one is going to be a little tricky. Basicly im wanting to have a button that when clicked will change status from 0 to 20 in table ladder_7 but only if rank is rank 1 through 16. I dont even know where to being on this lol
Link to comment
Share on other sites

Hey you helped me last time :)
I dont have any explantion because i dont know where to start on this one. Ill try to explain a little bit better.

The script is for a gaming ladder. Basicly the Ladder shows rank 1-25 on the first page. and then 26-50 on another page, etc.

During tournament time we always lock the top 16 teams so they can play in the tournamanent. To achieve this we edit team and add a lock, wich changes "status" in table "ladders_7" from "0" to "20".
0 = unlocked
20= locked.

So what im trying to do is devleope a script to add to a page where the admins do not have to do this manually to every time. They can click one button that will lock the top 16.

It would change "status" to "20" in table "ladders_7" but it would only change the status for the top 16 clans and not every clan.
Link to comment
Share on other sites

Oh ok...

The sql for that should be quite simple...

[code=php:0]$sql = "UPDATE ladders_7 SET status = 20 WHERE rank <= 16";
[/code]

That should do the trick.  This assumes that there's only one team to each rank, e.g. no joint 1st place etc.  Also that your table column for rank is called rank.

If teams can share rank then you can still do it by using the following command...


[code=php:0]$sql = "UPDATE ladders_7 SET status = 20 ORDER BY rank LIMIT 16";
[/code]

It's an odd query, but valid I believe.

Regards
Huggie
Link to comment
Share on other sites

A little more help if you can. If not I do appreciate you this far.
Here is the code template im working with for the admin panel.

<?
if(!IsSet($indexloaded)){
header("Location: ./index.php");
}

$checkaccess=mysql_query("SELECT * FROM staff1 WHERE id='$admn[id]'");
$ca=mysql_fetch_array($checkaccess);
if((!$ca[gmode]) AND (!$ca[mastera])){
if(!$ca[eteam]){
include("$dir[func]/error.php");
display_error("You are not allowed to Edit Teams.<br>");
}
}

/*
//CHECK ADMIN ACCESS LEVEL
if($admn[access] < 15){
include("$dir[func]/error.php");
display_error("You are not allowed to perform this function.<br>");
}
*/

$tablehead=table_head("show","700","","left");
$tablefoot=table_foot("show");

$out[body] = $out[body]."
<center>
$tablehead
<center><strong><font color='$style[headerfont]'>Lock top 16</font></strong></center><br>
<hr color='$style[headerfont]' size='1'>
<br>

This will lock all the top 16 for Rouge Spear Only. Used only for tournaments. Any other use will result in termination.
<br><br>

[color=red][font=Verdana]I NEED BUTTON HERE[/font][/color]

$tablefoot
";

include("$dir[curtheme]");

?>



I dont know how to put mysql commands to a button, im gonna keep looking for a toturial just in case.
Link to comment
Share on other sites

Add the button to the page by pasting the following code in where you want the button:

[code]
<form name="update" method="GET" action="$_SERVER['PHP_SELF']">
  <input type="submit" name="submit" value="Lock top 16">
</form>
[/code]

Then paste this into the php...

[code]
<?php
if (isset($_GET['submit'])){
  $sql = "UPDATE ladders_7 SET status = 20 WHERE rank <= 16";
  $result = mysql_query($sql) or die ("Cannot execute $sql: " . mysql_error());
  if ($result == true){
      echo "Top 16 successfully locked";
  }
  else {
      echo "Error while locking top 16";
  }
}
?>
[/code]

Regards
Huggie
Link to comment
Share on other sites

I am so sorry =[. Here is the error i get in browser.

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /var/www/vhosts/cgl-league.net/httpdocs/functions/admin_top16lock.php on line 49


Here is the code

<?
if(!IsSet($indexloaded)){
header("Location: ./index.php");
}

$checkaccess=mysql_query("SELECT * FROM staff1 WHERE id='$admn[id]'");
$ca=mysql_fetch_array($checkaccess);
if((!$ca[gmode]) AND (!$ca[mastera])){
if(!$ca[eteam]){
include("$dir[func]/error.php");
display_error("You are not allowed to Edit Teams.<br>");
}
}

/*
//CHECK ADMIN ACCESS LEVEL
if($admn[access] < 15){
include("$dir[func]/error.php");
display_error("You are not allowed to perform this function.<br>");
}
*/

if (isset($_GET['submit'])){
$sql = "UPDATE ladder_7 SET status = 20 WHERE rank <= 16";
$result = mysql_query($sql) or die ("Cannot execute $sql: " . mysql_error());
if ($result == true){
echo "Top 16 successfully locked";
}
else {
echo "Error while locking top 16";
}
}


$tablehead=table_head("show","700","","left");
$tablefoot=table_foot("show");

$out[body] = $out[body]."
<center>
$tablehead
<center><strong><font color='$style[headerfont]'>Lock top 16</font></strong></center><br>
<hr color='$style[headerfont]' size='1'>
<br>

This will lock all the top 16 for Rouge Spear Only. Used only for tournaments. Any other use will result in termination.
<br><br>

<center>
<form name=update method=GET action=$_SERVER['PHP_SELF']>
<input type=submit name=submit value=Lock top 16>
</form>
</center<

$tablefoot
";

include("$dir[curtheme]");

?>

Any Suggestions?
Link to comment
Share on other sites

Jester,

Try to use [b][[/b][b]code][/b] [b][/[/b][b]code][/b] tags when posting your code.

Give this a try...

[code]
<?php
if(!IsSet($indexloaded)){
  header("Location: ./index.php");
}

$checkaccess=mysql_query("SELECT * FROM staff1 WHERE id='$admn[id]'");
$ca=mysql_fetch_array($checkaccess);
if((!$ca[gmode]) AND (!$ca[mastera])){
  if(!$ca[eteam]){
      include("$dir[func]/error.php");
      display_error("You are not allowed to Edit Teams.");
  }
}

/*
//CHECK ADMIN ACCESS LEVEL
if($admn[access] < 15){
  include("$dir[func]/error.php");
  display_error("You are not allowed to perform this function.");
}
*/

if (isset($_GET['submit'])){
  $sql = "UPDATE ladder_7 SET status = 20 WHERE rank <= 16";
  $result = mysql_query($sql) or die ("Cannot execute $sql: " . mysql_error());
  if ($result == true){
      echo "Top 16 successfully locked";
  }
  else {
      echo "Error while locking top 16";
  }
}


$tablehead=table_head("show","700","","left");
$tablefoot=table_foot("show");

$out[body] .= <<<HTML
<center>
{$tablehead}
<center><strong><font color="{$style[headerfont]}">Lock top 16</font></strong></center>

<hr color="{$style[headerfont]}" size="1">



This will lock all the top 16 for Rouge Spear Only. Used only for tournaments. Any other use will result in termination.




<center>
<form name="update" method="GET" action="{$_SERVER['PHP_SELF']}">
<input type="submit" name="submit" value="Lock top 16">
</form>
</center>

{$tablefoot}
HTML;

include("$dir[curtheme]");

?>[/code]

Regards
Huggie
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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