rwwd Posted September 23, 2010 Share Posted September 23, 2010 Oop's I type OTF so mistakes are possible:- EDIT: $adminLinks, $honoredLinks, $memberLinks = ""; Yes, this IS how I declare vars in my class, they need spaces in methinks.. Or just do this to ensure no errors That line, do this to:- $adminLinks=$honoredLinks=$memberLinks = ""; or $adminLinks="" ;$honoredLinks=""; $memberLinks = ""; Really, that should have worked, I declare vars like that in my class's, Oh well. And, remove the extra " on this line:- $adminLinks .= ""<a href=\"profile.php?id=".$row['id']."\">".$row['username']."</a>\n\r"; I'm very tired, up in 6 hours for more coding \0/ Rw Quote Link to comment Share on other sites More sharing options...
snallemap Posted September 23, 2010 Author Share Posted September 23, 2010 Oop's I type OTF so mistakes are possible:- This line, do this to:- $adminLinks=$honoredLinks=$memberLinks = ""; or $adminLinks="" ;$honoredLinks=""; $memberLinks = ""; Really, that should have worked, I declare vars like that in my class's, Oh well. And, remove the extra " on this line:- $adminLinks .= ""<a href=\"profile.php?id=".$row['id']."\">".$row['username']."</a>\n\r"; I'm very tired, up in 6 hours for more coding \0/ Rw Changed that line now theres still a problem with the other line though... $adminLinks .= ""<a href=\"profile.php?id=".$row['id']."\">".$row['username']."</a>\n\r"; Just had to remove one of the " in the line then it worked, but the outcome was far from what i had in mind, this is what appeared: 42114There are no administrators. snalle test snallesnal bulle There are no administrators. snalle test snallesnal bulle Quote Link to comment Share on other sites More sharing options...
rwwd Posted September 23, 2010 Share Posted September 23, 2010 <?php include "config.php"; $sql = "SELECT `id`, `username`, `status` FROM `gusers` "; $result = mysql_query($sql) or die (mysql_error()); echo $rows = mysql_num_rows($result); if ($rows > 0) { $adminLinks = ""; $honoredLinks =""; $memberLinks = ""; while ($row = mysql_fetch_assoc($result)){ //see what is in the actuall value being checked/switched over print_r($row['status']); //change to suit - could do with a default case in this, but get it functional first switch ($row['status']){ case '1': $memberLinks .= "<a href=\"profile.php?id=".$row['id']."\">".$row['username']."</a>\n\r"; break; case '2' or '3': $honoredLinks .= "<a href=\"profile.php?id=".$row['id']."\">".$row['username']."</a>\n\r"; break; case '4': $adminLinks .= "<a href=\"profile.php?id=".$row['id']."\">".$row['username']."</a>\n\r"; break; } } if (empty($adminLinks)) { $adminLinks = "There are no administrators."; } if (empty($honoredLinks)) { $adminLinks = "There are no honored members."; } if (empty($memberLinks)) { $adminLinks = "There are no members."; } echo $adminLinks . "<br>" . $honoredLinks . "<br>" . $memberLinks; } //and for the hell of it see where we are with the others echo $adminLinks . "<br>" . $honoredLinks . "<br>" . $memberLinks; ?> Quote Link to comment Share on other sites More sharing options...
snallemap Posted September 23, 2010 Author Share Posted September 23, 2010 You did no changes except fixing the line in that code right? Still the same result atleast: 42114There are no administrators. snalle test snallesnal bulle There are no administrators. snalle test snallesnal bulle Quote Link to comment Share on other sites More sharing options...
snallemap Posted September 23, 2010 Author Share Posted September 23, 2010 By the way, this is the script all before we started attempting to add headlines: <?php include "config.php"; $sql = "SELECT id, username FROM gusers"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { echo "<a href='profile.php?id={$row['id']}'>{$row['username']} </br> </a>"; } } } ?> If anyone find that easier to work with then please do, im eager to get this fixed... but i just cant seem to do it Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted September 23, 2010 Share Posted September 23, 2010 By the way, this is the script all before we started attempting to add headlines: <?php include "config.php"; $sql = "SELECT id, username FROM gusers"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { echo "<a href='profile.php?id={$row['id']}'>{$row['username']} </br> </a>"; } } } ?> If anyone find that easier to work with then please do, im eager to get this fixed... but i just cant seem to do it If have the feeling, and i expressed it sneaky before, that your query isn't outputting the ranks or as you call it status. you query selects id and username. But the switch requires that status. I think that (which was in the first version already noted ) and I could be wrong, but I can't see how the switch can know the status if you don't select it. If you manage to output with you very first version the id username and status. and output everything. I am happy to write that switch again. But I bet if you just alter the sql query you should be fine Quote Link to comment Share on other sites More sharing options...
snallemap Posted September 23, 2010 Author Share Posted September 23, 2010 By the way, this is the script all before we started attempting to add headlines: <?php include "config.php"; $sql = "SELECT id, username FROM gusers"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { echo "<a href='profile.php?id={$row['id']}'>{$row['username']} </br> </a>"; } } } ?> If anyone find that easier to work with then please do, im eager to get this fixed... but i just cant seem to do it If have the feeling, and i expressed it sneaky before, that your query isn't outputting the ranks or as you call it status. you query selects id and username. But the switch requires that status. I think that (which was in the first version already noted ) and I could be wrong, but I can't see how the switch can know the status if you don't select it. This is the first one, i have selected status on the other ones So thats not the problem Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted September 23, 2010 Share Posted September 23, 2010 hmm ok, well I am bit to tired at the moment. I am gonna sleep and let my brains regain energy. But I am ppretty sure If you have that starting function just working with id username and status (and working!!!) it's easier to isolate the problem in the part after that. Quote Link to comment Share on other sites More sharing options...
snallemap Posted September 23, 2010 Author Share Posted September 23, 2010 Alright goodnight and thanks I hope that i can get it fixed or else that someone can help me get it fixed Never thought adding headlines under different values would be such a big deal Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted September 23, 2010 Share Posted September 23, 2010 Alright goodnight and thanks I hope that i can get it fixed or else that someone can help me get it fixed Never thought adding headlines under different values would be such a big deal It isn't i am pretty sure, just in the meanwhile try to get it to output all the values as you want. (including status and make sure the database entries have a status assigned and are not NULL!!) Ones that function works we are going to add the switch. Quote Link to comment Share on other sites More sharing options...
snallemap Posted September 23, 2010 Author Share Posted September 23, 2010 <?php include "config.php"; $sql = "SELECT id, username, status FROM gusers"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { echo "<a href='profile.php?id={$row['id']}'>{$row['username']} </br> </a>"; } } } ?> There! Theres none of the accounts with a 0 in their status value. Does that mean we are ready to add the switch ? Quote Link to comment Share on other sites More sharing options...
snallemap Posted September 24, 2010 Author Share Posted September 24, 2010 Once you guys wake up again i really hope we can go for a second attempt to fix this Quote Link to comment Share on other sites More sharing options...
snallemap Posted September 24, 2010 Author Share Posted September 24, 2010 Still nothing Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted September 24, 2010 Share Posted September 24, 2010 I am awake ;-) hmm that's odd it seems your script is edited. When i went to bed i had a small glimpse and i didn't saw you select status, but noow you have. could you just for testing purposes run: <?php include "config.php"; $sql = "SELECT id, username, status FROM gusers"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { echo "<a href='profile.php?id={$row['id']}'>{$row['username']}</a> and status = {$row['status']} <br />"; } } } ?> Btw i just noticed that you had a <br /> inside your <a href> </a> thats a bad thing You break and or newline behind it Anyways just run exactly what i just gave and tell what you see. Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted September 24, 2010 Share Posted September 24, 2010 change the echo with this echo '<a href="profile.php?id='.$row['id'].'">'.$row['username'].'</a> and status ='.$row['status']; I rather have it surrounded by single quotes. so the code i like you to run is: <?php include "config.php"; $sql = "SELECT id, username, status FROM gusers"; if ($result == mysql_query($sql)) { // i changed this because a single = is an assignment if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { echo '<a href="profile.php?id='.$row['id'].'">'.$row['username'].'</a> and status ='.$row['status'].'<br />'; } } } ?> Quote Link to comment Share on other sites More sharing options...
snallemap Posted September 24, 2010 Author Share Posted September 24, 2010 snalle and status =2 snallesnal and status =1 bulle and status =1 test and status =4 Thats the outcome, just to make clear i want something like this: Admin: - All with status 4 here Honored Members - All with status 2 and 3 here Members - All with status 1 here Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted September 24, 2010 Share Posted September 24, 2010 snalle and status =2 snallesnal and status =1 bulle and status =1 test and status =4 Thats the outcome, just to make clear i want something like this: Admin: - All with status 4 here Honored Members - All with status 2 and 3 here Members - All with status 1 here Your more than clear on what you want, but first things first... i have seen some really odd things even before we came to the switch things. Are what is outputed links??? the first part (please be a bit more precise on what is going on, this is taking much more time than is needed I am sure) Quote Link to comment Share on other sites More sharing options...
snallemap Posted September 24, 2010 Author Share Posted September 24, 2010 All the link outputs is perfect, no problems there It gets you right to their profile page. Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted September 24, 2010 Share Posted September 24, 2010 All the link outputs is perfect, no problems there It gets you right to their profile page. Ok good, now we have this working and all, we add the switch (finally ). Small question did you double the = sign in if ($result == mysql_query($sql)) ? if not and it's working its really odd Quote Link to comment Share on other sites More sharing options...
snallemap Posted September 24, 2010 Author Share Posted September 24, 2010 I did not double the = ... But ill do it now and this is the result of it: Notice: Undefined variable: result in C:\wamp\www\kawaii\memberlist.php on line 6 So lets go with = ? xD Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted September 24, 2010 Share Posted September 24, 2010 I did not double the = ... But ill do it now and this is the result of it: Notice: Undefined variable: result in C:\wamp\www\kawaii\memberlist.php on line 6 So lets go with = ? xD hmm yeah, but its weird for me. Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted September 24, 2010 Share Posted September 24, 2010 Ok can you run this? <?php include "config.php"; $sql = "SELECT id, username, status FROM gusers"; if ($result = mysql_query($sql)) { // i changed this because a single = is an assignment if (mysql_num_rows($result)) { $adminLinks = ""; $honoredLinks =""; $memberLinks = ""; //set vars while ($row = mysql_fetch_assoc($result)) { switch ($row['status']){ case '1': $memberLinks .= "<a href=\"profile.php?id=".$row['id']."\">".$row['username']."</a>\n\r"; break; case '2' or '3': $honoredLinks .= "<a href=\"profile.php?id=".$row['id']."\">".$row['username']."</a>\n\r"; break; case '4': $adminLinks .= "<a href=\"profile.php?id=".$row['id']."\">".$row['username']."</a>\n\r"; break; } } } } echo $adminLinks . "<br>" . $honoredLinks . "<br>" . $memberLinks; ?> AND after that <?php include "config.php"; $sql = "SELECT id, username, status FROM gusers"; $result = mysql_query($sql); // I REMOVED THE IF STATEMENT if (mysql_num_rows($result)) { $adminLinks = ""; $honoredLinks =""; $memberLinks = ""; //set vars while ($row = mysql_fetch_assoc($result)) { switch ($row['status']){ case '1': $memberLinks .= "<a href=\"profile.php?id=".$row['id']."\">".$row['username']."</a>\n\r"; break; case '2' or '3': $honoredLinks .= "<a href=\"profile.php?id=".$row['id']."\">".$row['username']."</a>\n\r"; break; case '4': $adminLinks .= "<a href=\"profile.php?id=".$row['id']."\">".$row['username']."</a>\n\r"; break; } } } echo $adminLinks . "<br>" . $honoredLinks . "<br>" . $memberLinks; ?> this last one doesn't have that if statement Quote Link to comment Share on other sites More sharing options...
snallemap Posted September 24, 2010 Author Share Posted September 24, 2010 Result of the first: snalle test snallesnal bulle Result of the next: snalle test snallesnal bulle Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted September 24, 2010 Share Posted September 24, 2010 OK i would move on with the last one because it's not generating any errors at my place. SO now your missing the headers right? lets add them: <?php include "config.php"; $sql = "SELECT id, username, status FROM gusers"; $result = mysql_query($sql); // I REMOVED THE IF STATEMENT if (mysql_num_rows($result)) { $adminLinks = ""; $honoredLinks =""; $memberLinks = ""; //set vars while ($row = mysql_fetch_assoc($result)) { switch ($row['status']){ case '1': $memberLinks .= "<a href=\"profile.php?id=".$row['id']."\">".$row['username']."</a>\n\r"; break; case '2' or '3': $honoredLinks .= "<a href=\"profile.php?id=".$row['id']."\">".$row['username']."</a>\n\r"; break; case '4': $adminLinks .= "<a href=\"profile.php?id=".$row['id']."\">".$row['username']."</a>\n\r"; break; } } } echo "admins: ".$adminLinks . "<br>Honored: " . $honoredLinks . "<br>Members: " . $memberLinks; // just changed this ?> Quote Link to comment Share on other sites More sharing options...
snallemap Posted September 24, 2010 Author Share Posted September 24, 2010 admins: Honored: snalle test Members: snallesnal bulle test should have been under admins since he got status 4 :/ ? Quote Link to comment 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.