lJesterl Posted October 1, 2006 Share Posted October 1, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/22691-updating-specific-rows/ Share on other sites More sharing options...
HuggieBear Posted October 1, 2006 Share Posted October 1, 2006 Are you able to provide an example in your explanation, maybe some test data, as I found the description a little confusing.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/22691-updating-specific-rows/#findComment-102024 Share on other sites More sharing options...
lJesterl Posted October 1, 2006 Author Share Posted October 1, 2006 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 = unlocked20= 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. Quote Link to comment https://forums.phpfreaks.com/topic/22691-updating-specific-rows/#findComment-102028 Share on other sites More sharing options...
HuggieBear Posted October 1, 2006 Share Posted October 1, 2006 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.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/22691-updating-specific-rows/#findComment-102031 Share on other sites More sharing options...
lJesterl Posted October 1, 2006 Author Share Posted October 1, 2006 Yea 1 team per rank. Thank you very much huggie. You are my hero Quote Link to comment https://forums.phpfreaks.com/topic/22691-updating-specific-rows/#findComment-102034 Share on other sites More sharing options...
lJesterl Posted October 1, 2006 Author Share Posted October 1, 2006 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 LEVELif($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. Quote Link to comment https://forums.phpfreaks.com/topic/22691-updating-specific-rows/#findComment-102037 Share on other sites More sharing options...
HuggieBear Posted October 1, 2006 Share Posted October 1, 2006 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]<?phpif (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]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/22691-updating-specific-rows/#findComment-102040 Share on other sites More sharing options...
lJesterl Posted October 1, 2006 Author Share Posted October 1, 2006 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 49Here 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 LEVELif($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? Quote Link to comment https://forums.phpfreaks.com/topic/22691-updating-specific-rows/#findComment-102045 Share on other sites More sharing options...
HuggieBear Posted October 2, 2006 Share Posted October 2, 2006 Jester,Try to use [b][[/b][b]code][/b] [b][/[/b][b]code][/b] tags when posting your code.Give this a try...[code]<?phpif(!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 LEVELif($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]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/22691-updating-specific-rows/#findComment-102149 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.