PC Nerd Posted January 8, 2007 Author Share Posted January 8, 2007 ok, thanksi basically used that thread's code, and have addapted it do this:[code]include("inc_files\Database_link.inc");$rank_query = "SELECT User_Name FROM General_Stats order by Rank DESC";if ($Rank_Query_Result = mysqli_query($DB_Server, $rank_query)) { if (mysqli_num_rows($Rank_Query_Result) > 0) { $current_rank = 1; while ($row = mysqli_fetch_assoc($Rank_Query_Result)) { $current_rank++; } }}[/code]now thats works fine and its being submitted to the database and all.BUT when im vewing the database in phpmyadmin, there is never a Rank:2, it goes 1345678...... and so on.???is it something to do with my loop??? i cant tell.and one other thing, what does mysqli_fetch_assoc(); do???, i dont understand it Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/page/2/#findComment-155433 Share on other sites More sharing options...
trq Posted January 8, 2007 Share Posted January 8, 2007 That code doesn't submit anything to the database. Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/page/2/#findComment-155436 Share on other sites More sharing options...
PC Nerd Posted January 8, 2007 Author Share Posted January 8, 2007 no, but it gives me the the rank integer, so becauase the problem is with the integer, it is poobably the loop that has the pgoblem Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/page/2/#findComment-155438 Share on other sites More sharing options...
trq Posted January 8, 2007 Share Posted January 8, 2007 Nope. That loop will always produce 1,2,3,4,5 etc etc until it ends. Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/page/2/#findComment-155442 Share on other sites More sharing options...
PC Nerd Posted January 8, 2007 Author Share Posted January 8, 2007 ok, this is the rest of the code:[code]<?phpinclude("inc_files\Database_link.inc");$rank_query = "SELECT User_Name FROM General_Stats order by Rank DESC";if ($Rank_Query_Result = mysqli_query($DB_Server, $rank_query)) { if (mysqli_num_rows($Rank_Query_Result) > 0) { $current_rank = 1; while ($row = mysqli_fetch_assoc($Rank_Query_Result)) { $current_rank++; } }}$User_Name = $_POST['User_Name'];$Password = $_POST['Password'];$Email = $_POST['Email'];$Security_Number = $_POST['Security_Number'];$F_Name = $_POST['F_Name'];$L_Name = $_POST['L_Name'];$Age = $_POST['Age'];$_POST['Created'] = date("d/m/Y H-i-s");$Created = $_POST['Created'];$_POST['Rank'] = $current_rank + 1;$Rank = $_POST['Rank'];$to = $Email;$subject = "New Battle Ages Acccount Confirmation";$Message = "To ".$F_Name."<br>";$Message = $Message."User Name :".$User_Name."<br>";$Message = $Message."Password :".$Password."<br>";$Message = $Message."Security Number :".$Security_Number."<br><br>";$Message = $Message."Please type your Security Number into the field below ( with no spaces or dash's), to activate your account";$Message = $Message."Thankyou for signing up to Battle-Ages. Please email us a the above address for help and support.<br><br>Yours, Battle-Ages Administraion Team";$header = "From: admin@battle-ages.itsmyland.com";$Send_Mail = mail($to, $subject, $Message, $header);$New_Player_SQL = "INSERT INTO General_Stats (User_Name, `Password`, Email, Security_Number, F_Name, L_Name, Age, Created, Rank, Level) VALUES ('$User_Name', '$Password', '$Email', '$Security_Number', '$F_Name', '$L_Name', '$Age', '$Created', '$Rank', '1')";$New_Player_Query = mysqli_query($DB_Server, $New_Player_SQL)or die("<h3>Error</h3>\n<br><br>\n<p>An error has occured while submitting your details to the Database. As a result your account has not been created, although you may still receive your confirmation email. If you do receive your Email, please ignore it, and resubmit your account request in 24 hours.</p><br><br>".mysqli_error($DB_Server)."SQL= ".$New_Player_SQL);echo "<center><h2>Success</h3></center>\n<br><br>\n<p>Your account has been added to our database. Once you receive your confirmation email, follow the link, and your account will be activated, after which you will be able to play on Battle-Ages whenever you wish. If however your email only allows text-only emails, then please contact us at admin@battle-ages.itsmyland.com and we will activate your account manually.</p>";echo "<br><br>";echo "The Final data that is in the database is :";echo "<br><br>\n";echo "User_Name:".$User_Name;echo "\n<br>\n";echo "Password: ".$Password;echo "\n<br>\n";echo "Email: ".$Email;echo "\n<br>\n";echo "Security Number: ".$Security_Number;echo "\n<br>\n";echo "First Name: ".$F_Name;echo "\n<br>\n";echo "Last Name: ".$L_Name;echo "\n<br>\n";echo "Age: ".$Age;echo "\n<br>\n";?>[/code]thats all of the php..... and the database stuff and everything..... thats all=so the same page ive got the other thread about the smtp error going, if you can help there.... ? Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/page/2/#findComment-155445 Share on other sites More sharing options...
trq Posted January 8, 2007 Share Posted January 8, 2007 Honestly, youve missed the whole point of the other thread I suggested to read. Logically I think youve gone about the whole problem the wrong way. I think Im done suggesting solutions. Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/page/2/#findComment-155448 Share on other sites More sharing options...
PC Nerd Posted January 8, 2007 Author Share Posted January 8, 2007 its ok, i had added one to many increments, so that i was missing the 2... ok thats working ok Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/page/2/#findComment-155451 Share on other sites More sharing options...
trq Posted January 8, 2007 Share Posted January 8, 2007 If you insist on going your route at least lets do what you want a little more efficiently. You dont need a loop to get the total number of users in your General_Stats table.[code=php:0]if ($result = mysqli_query("SELECT COUNT(*) AS ttl FROM General_Stats")) { if (mysqli_num_rows($result) > 0) { $row = $row = mysqli_fetch_assoc($result); $current_rank = $row['ttl']; }}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/33188-solved-creating-a-rank-field-but-decrementing-values/page/2/#findComment-155453 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.