Jump to content

Greysoul

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Everything posted by Greysoul

  1. yeah seems as if i have a cron manager so it pretty much schedules it and everything for me..all i have to do is assign a script to run on whatever day and time i want. thanks a lot!
  2. none after the 28th and i've never heard of cron until now guess i'll have to take a look at that then ;o my host is godaddy so i'm checking to see if thats something they support.
  3. so im trying to setup a page for my bills that i pay monthly so me and my gf can access it remotely whenever we need to. we have a few loans that we are paying off in installment loans every month so i created a table like the picture below (which is actually in excel but it looks about the same). i know how to pull via select and sum everything that i need but what i'm actually going for is this: every month on those certain due dates i'd like for the monthly payment to be subtracted from the balance automatically..and it show the reflected balance. i'm not sure how to go about such a thing though as i've never worked with dates and times. my logic is that i have to setup a beginning time stamp for it to work off of..and then every 30 days from that time stamp..subtract the payment. then again, there's not always 30 days in a month and it'd get off track. any ideas? [attachment deleted by admin]
  4. i just realized later on i will need to set a minimum of games played..like when there's 10 games played i'd need only players with a minimum of 4 games played to be eligible to be shown. if i change my where clause to...WHERE gp > 3...it just says gp is an unknown column. if i say WHERE Count(Player) > 3..it says invalid group function or something.
  5. nevermind, figured it out! $score=mysql_query("SELECT *, Count(Player) AS gp, (SUM(Score) / COUNT(Player)) AS spg FROM Scorecard WHERE Score > 0 GROUP BY Player ORDER BY spg DESC Limit 0,10") or die(mysql_error());
  6. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/greysoul/public_html/o/leaders.php on line 99 and if i change to mysql error... Unknown column 'gp' in 'field list' so yeah its pulling from the table in that division instead of the alias i assigned
  7. i'm guessing its because i have it defining gp and score, and then using the two in a math problem directly after. if this is wrong, how would i go about correcting it? fyi... gp=games played, its tallying the amount of times the player is listed to say how many games they played in. score=a score of kills after deaths, its just a number spg=of course is average score per games played in function pspg(){ $score=mysql_query("SELECT *, COUNT(Player) AS gp, SUM(Score) AS score, (score/gp) AS spg FROM Scorecard WHERE score > 0 GROUP BY Player ORDER BY spg DESC Limit 0,10"); echo "<table>"; echo "<tr> <th class='th'>Rank</th> <th class='th'>Pilot</th> <th class='th'>Clan</th> <th class='th'>GP</th> <th class='th'>SPG</th></tr>"; while($ps=mysql_fetch_array($score)){ echo "<tr>"; echo "<td class='tdp'>" . ++$i . "</td>"; echo "<td class='tdp'>" . '<a href=o.php?p=' . $ps['Player'] . '>' . $ps['Player'] . '</a>' . "</td>"; echo "<td class='tdp'>" . '<a href=o.php?c=' . $ps['Clan'] . '>' . $ps['Clan'] . '</a>' . "</td>"; echo "<td class='tdp'>" . $ps['gp'] . "</td>"; echo "<td class='tdp'>" . round($ps['spg'], 2) . "</td>"; echo "</tr>"; } echo "</table>"; echo "<br>"; }
  8. oh my, that certainly worked. i've never even heard of GROUP BY. i'm kind of a beginner, what does that do exactly? unfortunately my common sense isn't kicking in.
  9. yeah you'd have to change the query to preform the action i'm trying to get, what i showed you was how i got the results for one name. that's also partly what i need help with i suppose.
  10. hello all, i'm trying to tackle something thats been owning me as of late. my db is for a league in a game, where you insert stats so that people can view results of games. this is stored in the table, Scorecard. there's many games, so there are duplicate player name entries. I'm using this table to also display my results on the page. i can easily use the SUM() in my query to add up all of one players stats on his personal page. on the clan webpage, it shows every players stats listed in a table. if i add WHERE Clan='NoF', it ends up tallying up every player in that said clan and only showing one name. this is how i make it show a result of just one player, as if its on that players specific page only. how do i get this to loop for each player on the clan page to make it look like this for example: http://sparkgn.com/d.php?p=clan&&clan=12 instead of just http://sparkgn.com/d.php?p=player&&player=216 (ignore game statistics, i can do that fine already). any suggestions? $playersum=mysql_query(" SELECT *, Count(Player) AS pgp, SUM(Score) AS ps, SUM(Kills) AS pk, SUM(Deaths) AS pd, SUM(Attempts) AS pfa, SUM(Caps) AS pfc, SUM(MVP) AS pmvp FROM Scorecard WHERE Player='Greysoul'") or die(mysql_error()); while($psum=mysql_fetch_array($playersum)){ echo "<tr>"; echo "<td>".$psum['Player']."</td>"; echo "<td>".$psum['pgp']."</td>"; echo "<td>".$psum['ps']."</td>"; echo "<td>".$psum['pk']."</td>"; echo "<td>".$psum['pd']."</td>"; $pspg=$psum['ps'] / $psum['pgp']; echo "<td>".round($pspg, 2)."</td>"; $pkpg=$psum['pk'] / $psum['pgp']; echo "<td>".round($pkpg, 2)."</td>"; $pkd=$psum['pk'] / $psum['pd']; echo "<td>".round($pkd, 2)."</td>"; echo "<td>".$psum['pfa']."</td>"; echo "<td>".$psum['pfc']."</td>"; $pfp=$psum['pfc'] / $psum['pfa'] * 100; echo "<td>".round($pfp, 2). "%" ."</td>"; echo "<td>".$psum['pmvp']."</td>"; echo "</tr>"; } echo "</table>";
  11. had this working at some point with only one being deleted at a time, but through experiment i lost even that ability. this was my starter code. i'm posting my entire second page in case there's something interfering, but the delete info is near the bottom. i'm sure there's a quick fix, any ideas? as is, it deletes all rows even if none are checked. first page <? // Connect database. $host="localhost"; // Host name. $db_user="greysoul_gs"; // MySQL username. $db_password="test"; // MySQL password. $database="greysoul_leaguedb"; // Database name. mysql_connect($host,$db_user,$db_password); mysql_select_db($database); if (isset($_GET['clan'])) { $clanurl= $_GET['clan']; } // Select all data records in table "name_list" and put them into $result. $result=mysql_query("select * from Players WHERE ClanName='$clanurl' ORDER BY Player"); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>::Edit Clan and Player Info</title> </head> <body> <form id="form1" name="form1" method="post" action="clanplayerupdate.php"> <table border="1" cellpadding="3" cellspacing="0"> <tr> <td align="center" bgcolor="#FFCC00"><strong>Delete</strong></td> <td align="center" bgcolor="#FFCC00"><strong>Clan</strong></td> <td align="center" bgcolor="#FFCC00"><strong>Name</strong></td> <td align="center" bgcolor="#FFCC00"><strong>GP</strong></td> <td align="center" bgcolor="#FFCC00"><strong>Scores</strong></td> <td align="center" bgcolor="#FFCC00"><strong>Kills</strong></td> <td align="center" bgcolor="#FFCC00"><strong>Deaths</strong></td> <td align="center" bgcolor="#FFCC00"><strong>SPG</strong></td> <td align="center" bgcolor="#FFCC00"><strong>KPG</strong></td> <td align="center" bgcolor="#FFCC00"><strong>K/D</strong></td> <td align="center" bgcolor="#FFCC00"><strong>FA</strong></td> <td align="center" bgcolor="#FFCC00"><strong>FC</strong></td> <td align="center" bgcolor="#FFCC00"><strong>FP%</strong></td> <td align="center" bgcolor="#FFCC00"><strong>MVP</strong></td> </tr> <? // Fetch record rows in $result by while loop and put them into $row. $x = 0; while($row=mysql_fetch_assoc($result)){ ?> <tr> <td align="center" bgcolor="#FFCC00"><strong><input type="checkbox" name="delete" id="<?=$row[iD]?>" value="<?=$row[iD]?>"></strong></td> <td bgcolor="#FFFFCC"><input name="<? echo 'clanName'.$x; ?>" size="4" type="text" id="<? echo $row['ClanName']; ?>" value="<? echo $row['ClanName']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo 'playerName'.$x; ?>" size="15" type="text" id="<? echo $row['Player']; ?>" value="<? echo $row['Player']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo 'gp'.$x; ?>" size="4" type="text" id="<? echo $row['GP']; ?>" value="<? echo $row['GP']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo 'scores'.$x; ?>" size="4" type="text" id="<? echo $row['Scores']; ?>" value="<? echo $row['Scores']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo 'kills'.$x; ?>" size="4" type="text" id="<? echo $row['Kills']; ?>" value="<? echo $row['Kills']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo 'deaths'.$x; ?>" size="4" type="text" id="<? echo $row['Deaths']; ?>" value="<? echo $row['Deaths']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo 'spg'.$x; ?>" size="4" type="text" id="<? echo $row['SPG']; ?>" value="<? echo $row['SPG']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo 'kpg'.$x; ?>" size="4" type="text" id="<? echo $row['KPG']; ?>" value="<? echo $row['KPG']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo 'kd'.$x; ?>" size="4" type="text" id="<? echo $row['KD']; ?>" value="<? echo $row['KD']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo 'fa'.$x; ?>" size="4" type="text" id="<? echo $row['FA']; ?>" value="<? echo $row['FA']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo 'fc'.$x; ?>" size="4" type="text" id="<? echo $row['FC']; ?>" value="<? echo $row['FC']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo 'fp'.$x; ?>" size="4" type="text" id="<? echo $row['FP']; ?>" value="<? echo $row['FP']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo 'mvp'.$x; ?>" size="4" type="text" id="<? echo $row['MVP']; ?>" value="<? echo $row['MVP']; ?>" /></td> <input type = "hidden" name = "<? echo 'id'.$x ?>" value = "<?echo $row[iD] ?>" /> </tr> <? $x++; } ?> <input type = "hidden" name = "size" value = "<?echo $x; ?>" /> </table> <input type="submit" name="Submit" value="Update" /> <input type="submit" name="delete" id="delete" value="Delete" /> </form> <?php $links=mysql_query("select * from Clans"); while($rows = mysql_fetch_array($links)) { echo '<a href="clanplayeredit.php?clan=' . $rows['ClanName'] . '">' . $rows['ClanName'] . '</a>' . " "; } ?> <br><br><br> <form onsubmit="return validate_form(this)" method="post" action="clanplayerupdate.php"> Player Name: <input type="text" name="Player0" size="20" /> Clan Tag: <input type="text" name="ClanName0" size="20" /> <br> Player Name: <input type="text" name="Player1" size="20" /> Clan Tag: <input type="text" name="ClanName1" size="20" /> <br> <input type="submit" value="Add" /> </form> </body> </html> second page <html> <body> <head> </head> <?php if($_POST['Submit']){ // If receive Submit button variable. // Connect database. $host="localhost"; // Host name. $db_user="greysoul_gs"; // MySQL username. $db_password="test"; // MySQL password. $database="greysoul_leaguedb"; // Database name. mysql_connect($host,$db_user,$db_password); mysql_select_db($database); $result=mysql_query("select Player from Players order by id asc"); $y = 0; while($y < $_POST[size]) { $player=$_POST["playerName".$y]; $clan = $_POST["clanName".$y]; $gp= $_POST["gp".$y]; $scores = $_POST["scores".$y]; $kills = $_POST["kills".$y]; $deaths = $_POST["deaths".$y]; $spg = $_POST["spg".$y]; $kpg = $_POST["kpg".$y]; $kd = $_POST["kd".$y]; $fa = $_POST["fa".$y]; $fc = $_POST["fc".$y]; $fp = $_POST["fp".$y]; $mvp = $_POST["mvp".$y]; $id = $_POST["id".$y]; mysql_query("UPDATE Players SET Player='$player', ClanName = '$clan', GP = '$gp', Scores = '$scores', Kills = '$kills', Deaths = '$deaths', SPG = '$spg', KPG = '$kpg', KD = '$kd', FA = '$fa', FC = '$fc', FP = '$fp', MVP = '$mvp' WHERE ID='$id'"); $y++; } echo "--- Update Complete ---" . "<br>" . "<br>"; } ?> <?php // DELETING CHECK BOXES $host="localhost"; // Host name. $db_user="greysoul_gs"; // MySQL username. $db_password="test"; // MySQL password. $database="greysoul_leaguedb"; // Database name. mysql_connect($host,$db_user,$db_password); mysql_select_db($database); if($_POST['delete']) { foreach($_POST as $playerdel) { // This will loop through the checked checkboxes mysql_query("DELETE FROM Players WHERE ID='$playerdel'"); // This deletes the record from the database } } ?> <?php if (isset($HTTP_REFERER)) { echo "<a href='$HTTP_REFERER'>Back</a>"; } else { echo "<a href='javascript:history.back()'>Click to Go Back</a>"; } ?> <br> <br> <?php $host="localhost"; // Host name. $db_user="greysoul_gs"; // MySQL username. $db_password="test"; // MySQL password. $database="greysoul_leaguedb"; // Database name. mysql_connect($host,$db_user,$db_password); mysql_select_db($database); $Playeradd= $_POST['Player0']; $ClanNameadd= $_POST['ClanName0']; $Player1add= $_POST['Player1']; $ClanName1add= $_POST['ClanName1']; $insert="INSERT INTO Players (ID, Player, ClanName)VALUES ('NULL','".$Playeradd."', '".$ClanNameadd."'), ('NULL','".$Player1add."', '".$ClanName1add."')"; mysql_query($insert) or die ('Error updating database'); ?> </body> </html>
  12. thanks for the response but my friend helped me out earlier today.
  13. for whatever weird reason it won't let me edit again. just wanted to say its safe to ignore most of the //'s...it was copied code where i changed variables. also the code above is where only the player name column works..i left it at that so you could see how far i had really gotten.
  14. So this is my problem; I'm starting to learn PHP and how it works with SQL. I run into problems non stop, and most of the time when i'm at my breaking point i find a solution via searching around the internet. I've found a lot of tutorials on Updating data in an SQL database. I now know how to update many rows at once with a single form, which is cool. My main problem is i'm utterly FAILING at updating two or more columns in a table ..with the same form. Basically i can display everything i want, but when i hit update..it all goes down hill. My second page Update query info is where i bomb out...no matter what variation i try it just doesn't work. If anyone can point me in the right direction to finish the code, i'd greatly appreciate it. I'll post a picture of what i'm trying to accomplish. first page <? // Connect database. $host="localhost"; // Host name. $db_user="test"; // MySQL username. $db_password="test"; // MySQL password. $database="test"; // Database name. mysql_connect($host,$db_user,$db_password); mysql_select_db($database); // Select all data records in table "name_list" and put them into $result. $result=mysql_query("select * from Players"); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form id="form1" name="form1" method="post" action="playerupdate.php"> <table border="1" cellpadding="3" cellspacing="0"> <td align="center" bgcolor="#FFCC00"><strong>Clan</strong></td> <td align="center" bgcolor="#FFCC00"><strong>Name</strong></td> <td align="center" bgcolor="#FFCC00"><strong>GP</strong></td> <td align="center" bgcolor="#FFCC00"><strong>Scores</strong></td> <td align="center" bgcolor="#FFCC00"><strong>Kills</strong></td> <td align="center" bgcolor="#FFCC00"><strong>Deaths</strong></td> <td align="center" bgcolor="#FFCC00"><strong>SPG</strong></td> <td align="center" bgcolor="#FFCC00"><strong>KPG</strong></td> <td align="center" bgcolor="#FFCC00"><strong>K/D</strong></td> <td align="center" bgcolor="#FFCC00"><strong>FA</strong></td> <td align="center" bgcolor="#FFCC00"><strong>FC</strong></td> <td align="center" bgcolor="#FFCC00"><strong>FP%</strong></td> <td align="center" bgcolor="#FFCC00"><strong>MVP</strong></td> </tr> <? // Fetch record rows in $result by while loop and put them into $row. while($row=mysql_fetch_assoc($result)){ ?> <tr> <td bgcolor="#FFFFCC"><input name="<? echo $row['ClanName']; ?>" size="4" type="text" id="<? echo $row['ClanName']; ?>" value="<? echo $row['ClanName']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo $row['Player']; ?>" size="15" type="text" id="<? echo $row['Player']; ?>" value="<? echo $row['Player']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo $row['GP']; ?>" size="4" type="text" id="<? echo $row['GP']; ?>" value="<? echo $row['GP']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo $row['Scores']; ?>" size="4" type="text" id="<? echo $row['Scores']; ?>" value="<? echo $row['Scores']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo $row['Kills']; ?>" size="4" type="text" id="<? echo $row['Kills']; ?>" value="<? echo $row['Kills']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo $row['Deaths']; ?>" size="4" type="text" id="<? echo $row['Deaths']; ?>" value="<? echo $row['Deaths']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo $row['SPG']; ?>" size="4" type="text" id="<? echo $row['SPG']; ?>" value="<? echo $row['SPG']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo $row['KPG']; ?>" size="4" type="text" id="<? echo $row['KPG']; ?>" value="<? echo $row['KPG']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo $row['KD']; ?>" size="4" type="text" id="<? echo $row['KD']; ?>" value="<? echo $row['KD']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo $row['FA']; ?>" size="4" type="text" id="<? echo $row['FA']; ?>" value="<? echo $row['FA']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo $row['FC']; ?>" size="4" type="text" id="<? echo $row['FC']; ?>" value="<? echo $row['FC']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo $row['FP']; ?>" size="4" type="text" id="<? echo $row['FP']; ?>" value="<? echo $row['FP']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="<? echo $row['MVP']; ?>" size="4" type="text" id="<? echo $row['MVP']; ?>" value="<? echo $row['MVP']; ?>" /></td> </tr> <? } // End while loop. ?> </table> <input type="submit" name="Submit" value="Update" /> </form> </body> </html> second page <? if($_POST['Submit']){ // If receive Submit button variable. // Connect database. $host="localhost"; // Host name. $db_user="test"; // MySQL username. $db_password="test"; // MySQL password. $database="test"; // Database name. mysql_connect($host,$db_user,$db_password); mysql_select_db($database); // Select all data records in table "name_list" and put them into $result. $result=mysql_query("select Player from Players order by id asc"); // Fetch record rows in $result by while loop and put them into $row. while($row=mysql_fetch_assoc($result)){ // Get the posted value "name_ID value" from form.php. This variable change it's value by while loop. $name=$_POST[$row[Player]]; // Update field "name", matching with "id" value by while loop. mysql_query("UPDATE Players SET Player='$name' WHERE Player='$row[Player]'"); } echo "--- Update Complete ---"; } ?> [attachment deleted by admin]
×
×
  • 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.