Jump to content

Appear under differnet headlines


snallemap

Recommended Posts

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

Link to comment
Share on other sites

  • Replies 55
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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

Link to comment
Share on other sites

<?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;
?>

Link to comment
Share on other sites

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 :(

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

<?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 ? :D

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 />';
    }
  }
}

?> 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

All the link outputs is perfect, no problems there :D It gets you right to their profile page. :D

 

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 :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
?>

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.