Page 1 of 1

help on code

Posted: Thu Feb 19, 2004 9:15 pm
by theanimewizard

Code: Select all

$getmembersno = explode(', ', $rowї'members']);
	$totalmembersno = count($getmembersno);
	for ($i = 0; $i < count($getmembersno); $i++) &#123;

	$p1sql = "select user_id, user_class from phpbb_users where username='$getmembersno&#1111;$i]'";
	if ( !($p1result = $db->sql_query($p1sql)) ) &#123; message_die(GENERAL_MESSAGE, 'Fatal Error Getting User Info!'); &#125;
	$p1row = mysql_fetch_array($p1result);
	$membernoid = $p1row&#1111;'user_id'];
	$membernoclass = $p1row&#1111;'user_class'];
	$membernoimagenumber = 2;
	$membersno .= "<a href="profile.php?mode=viewprofile&u=$membernoid"><img src="shop/uses/arena/arena_player_$membernoclass$membernoimagenumber.gif" border="0" alt="$getmembersno&#1111;$i] - $membernoclass"></a>"; &#125;

		$noclanrow .= "<form action="$clansfilename?action=want2join&clan=$dname" method="post"><tr><td class="row1"><span class="gen"><a href="$clansfilename?action=clanpage&clan=$dname" >".$row&#1111;'clanname']."</a></span></td><td class="row1"><span class="gen">".$row&#1111;'leader']."</span></td><td class="row1"><span class="gen">$membersno</span></td><td class="row1"><span class="gen">$totalmembersno</span></td><td class="row1"><span class="gen">".$row&#1111;'points']."</span></td><td class="row1"><span class="gen"><center>
		<input type="submit" class="mainoption" value=" Join "></center></span></td></tr></form>";
	&#125;

In $noclanrow... its showing stuff from other clans $membersno

for example,

clan 1 has Apple and Orange for $membersno
clan 2 has Banana
clan 3 has grapes

clan 1 shows Apple, Orange
Clan 2 is also showing apple and orange + banana..
Clan 3 is showing Apple Orange, Banana + Grapes!

i think its something with the .=

its cuz i repeat something in a repeating thing...



i want the clan rows to repeat. the membersno, only if it belongs to the same clan.

Posted: Fri Feb 20, 2004 12:48 am
by Pointybeard

Code: Select all

<?php
$getmembersno = explode(', ', $row['members']);
   $totalmembersno = count($getmembersno);

   for ($i = 0; $i < count($getmembersno); $i++) {
     $p1sql = "select user_id, user_class from phpbb_users where username='$getmembersno[$i]'";

   if ( !($p1result = $db->sql_query($p1sql)) ) {
    message_die(GENERAL_MESSAGE, 'Fatal Error Getting User Info!'); 
   }

   $p1row = mysql_fetch_array($p1result);
   $membernoid = $p1row['user_id'];
   $membernoclass = $p1row['user_class'];
   $membernoimagenumber = 2;

   $membersno .= "<a href="profile.php?mode=viewprofile&u=$membernoid">
<img src="shop/uses/arena/arena_player_$membernoclass$membernoimagenumber.gif" border="0" alt="$getmembersno[$i] - $membernoclass">
</a>";
 }

      $noclanrow .= "<form action="$clansfilename?action=want2join&clan=$dname" method="post">
<tr>
  <td class="row1">
    <span class="gen">
      <a href="$clansfilename?action=clanpage&clan=$dname" >".$row['clanname']."</a>
    </span>
  </td>
  <td class="row1">
    <span class="gen">".$row['leader']."</span>
  </td>
  <td class="row1">
    <span class="gen">$membersno</span>
  </td>
  <td class="row1">
    <span class="gen">$totalmembersno</span>
  </td>
  <td class="row1">
    <span class="gen">".$row['points']."</span>
  </td>
  <td class="row1">
    <span class="gen">
      <center>
        <input type="submit" class="mainoption" value=" Join ">
      </center>
    </span>
  </td>
</tr>
</form>";

}
?>
Easier to read now....

Posted: Fri Feb 20, 2004 12:54 am
by Pointybeard
Hmm...well im sorry, im finding it hard to follow since theres no data for reference (Apples, oranges and bananas is too abstract. hehe). I would suggest that you put a bunch of print() statements in there so you can trace whats happening and where. If you still cant figure it out, then just post up your findings.... :p

Posted: Fri Feb 20, 2004 7:42 am
by theanimewizard
Okie, here is whats happening


theres a table called phpbb_clans and theres a colum inthere called members, members in each clan are stored in that colum inside a cell.

for example

Clan Name | Members
Clan 1 | Apple, Orange
Clan 2 | Banana
Clan 3 | Grapes

What I did was explode the members so each member is an element. i think thats whats its called. or its called an array. im not sure

then i go and check at phpbb_users for info on EVERY MEMBER of a clan.

after that, I do the .= to repeat the findings for example

Username | ID | Class

Apple | 3 | Mage
Orange | 101 | Knight
Banana | 327 | Archer
Grapes | 532 | King


after I get all the info, I make a string called noclanrow, there it REPEATS for every clan.

my problem is

for noclanrow of clan 1, it shows Apple - 3 - Mage and Orange -101 - Knight

BUT FOR Clan #2, its getting the DATA from the previous clan and repeating it. now its showing Apple - 3 - Mage and Orange -101 - Knight
AND Banana | 327 | Archer


yeh, how do i make it so that, if $membersno repeats, it only repeats ONCE in noclanrow

Posted: Fri Feb 20, 2004 3:36 pm
by theanimewizard
nvm... i figured out a VERY COMPLICATED way to do it . lol. it takes SOO MUCH CODE XD