MyBB Community Forums

Full Version: query fid of user in certain group?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
K, it came up with a bunch of stuff... what are you looking for?
I just wanna know if the array actually contains data.

Can you run print_r on $tmp too?
everything is fine, i think it needs to pull the (uid) from the $arr and not the $user

When i did that, i got random output of a bunch of c's, r's z's, well, look lol: http://www.tgs.webege.com/forum/testphpdb.php
There's one too many foreach loop I think. I think the one I added might not be needed. Try taking it out and could you send me the print_r output of $tmp?

I'll have a look at it tomorrow.
Ok, I have this working... kind of. Here is the code:
<?php

define("IN_MYBB", 1);
$templatelist = "adLog";
require_once './global.php';
require_once './rsslib.php';

add_breadcrumb("Adventurer's Log", "adLog.php");

$output = '';
// $usergroup['clan_member']
if ($mybb->user['usergroup'] == 7) {
    error_no_permission();
} else {

    $que =$db->query("SELECT * FROM mybb_users WHERE usergroup=8");


    $output .= '<center><table width="100%">
       <tr colspan="2">
       <th colspan="2" class="thead"><div style="float:left; color:white;">The
       Great Spiritz Adventurer\'s Log</div><div style="float:right;"><input
       type="text" value="Search players"><input type="button" value="Search"></th>
       </tr>
       <tr>
       <td style="width:50%;" class="trow2 page_content"><center>Choose a clan
       member\'s name to view their Adventurer\'s Log.<br><br><div>';
   
    while ($arr =$db->fetch_array($que)) {
    foreach($arr as $user) {
    $answer = $db->query("SELECT * FROM mybb_userfields WHERE ufid=".$arr['uid']);

            while($tmp = $db->fetch_array($answer)){
             //foreach($tmp as $users){
               $output .= $tmp['fid5']."<br>\n";
                                   
                                                         }
                               }
                                         }
    
    
    $output .= '</div></center></td><td style="width:50%;" class="trow2 page_content">
       <center>Search for a player\'s Adventurer\'s Log.<br><br></center></td>
       </tr>
       <tr colspan="2"><td colspan="2" class="tcat"></td></tr>
       </table></center>';

    eval("\$adLog_home = \"".$templates->get("adLog"). "\";");
    output_page($adLog_home);
}

?>

and the page: http://www.tgs.webege.com/forum/testphpdb.php


What is causing it to show the same name multiple times and space it like that?
I don't think the while loop is needed either. Because $answer should only return one record.

This might solve the problem:

$tmp = $db->fetch_array($answer);
$output .= $tmp['fid5']."<br>\n";

Have that instead of the second while loop and it should fix the problem.
It didn't really make much of a difference Confused.

Code:
<?php

define("IN_MYBB", 1);
$templatelist = "adLog";
require_once './global.php';
require_once './rsslib.php';

add_breadcrumb("Adventurer's Log", "adLog.php");

$output = '';
// $usergroup['clan_member']
if ($mybb->user['usergroup'] == 7) {
    error_no_permission();
} else {

    $que =$db->query("SELECT * FROM mybb_users WHERE usergroup=8||1");

    $output .= '<center><table width="100%">
       <tr colspan="2">
       <th colspan="2" class="thead"><div style="float:left; color:white;">The
       Great Spiritz Adventurer\'s Log</div><div style="float:right;"><input
       type="text" value="Search players"><input type="button" value="Search"></th>
       </tr>
       <tr>
       <td style="width:50%;" class="trow2 page_content"><center>Choose a clan
       member\'s name to view their Adventurer\'s Log.<br><br><div>';
   
    while ($arr =$db->fetch_array($que)) {
    foreach($arr as $user) {
    $answer = $db->query("SELECT * FROM mybb_userfields WHERE ufid=".$arr['uid']);

            $tmp = $db->fetch_array($answer);
            $output .= $tmp['fid5']."<br>\n";
                           }                                                            
                }
                                         
    $output .= '</div></center></td><td style="width:50%;" class="trow2 page_content">
       <center>Search for a player\'s Adventurer\'s Log.<br><br></center></td>
       </tr>
       <tr colspan="2"><td colspan="2" class="tcat"></td></tr>
       </table></center>';

    eval("\$adLog_home = \"".$templates->get("adLog"). "\";");
    output_page($adLog_home);
}

?>
Try this:

<?php

define("IN_MYBB", 1);
$templatelist = "adLog";
require_once './global.php';
require_once './rsslib.php';

add_breadcrumb("Adventurer's Log", "adLog.php");

$output = '';
// $usergroup['clan_member']
if ($mybb->user['usergroup'] == 7) {
    error_no_permission();
} else {

    $que =$db->query("SELECT * FROM mybb_users WHERE usergroup=8||1");

    $output .= '<center><table width="100%">
       <tr colspan="2">
       <th colspan="2" class="thead"><div style="float:left; color:white;">The
       Great Spiritz Adventurer\'s Log</div><div style="float:right;"><input
       type="text" value="Search players"><input type="button" value="Search"></th>
       </tr>
       <tr>
       <td style="width:50%;" class="trow2 page_content"><center>Choose a clan
       member\'s name to view their Adventurer\'s Log.<br><br><div>';
   
    $arr =$db->fetch_array($que);
    foreach($arr as $user) {
    $answer = $db->query("SELECT * FROM mybb_userfields WHERE ufid=".$user['uid']);

            $tmp = $db->fetch_array($answer);
            $output .= $tmp['fid5']."<br>\n";
                           }                                                            
                                         
    $output .= '</div></center></td><td style="width:50%;" class="trow2 page_content">
       <center>Search for a player\'s Adventurer\'s Log.<br><br></center></td>
       </tr>
       <tr colspan="2"><td colspan="2" class="tcat"></td></tr>
       </table></center>';

    eval("\$adLog_home = \"".$templates->get("adLog"). "\";");
    output_page($adLog_home);
}

?>

I might be missing a } or have an extra one, but run it and see.
MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
    1054 - Unknown column 'C' in 'where clause'
Query:
    SELECT * FROM mybb_userfields WHERE ufid=C

thats just what i got right off the bat, i didn't look for anything missing
Damn, ok, the while loop needs to go back. Next try this:

<?php

define("IN_MYBB", 1);
$templatelist = "adLog";
require_once './global.php';
require_once './rsslib.php';

add_breadcrumb("Adventurer's Log", "adLog.php");

$output = '';
// $usergroup['clan_member']
if ($mybb->user['usergroup'] == 7) {
    error_no_permission();
} else {

    $que =$db->query("SELECT * FROM mybb_users WHERE usergroup=8||1");

    $output .= '<center><table width="100%">
       <tr colspan="2">
       <th colspan="2" class="thead"><div style="float:left; color:white;">The
       Great Spiritz Adventurer\'s Log</div><div style="float:right;"><input
       type="text" value="Search players"><input type="button" value="Search"></th>
       </tr>
       <tr>
       <td style="width:50%;" class="trow2 page_content"><center>Choose a clan
       member\'s name to view their Adventurer\'s Log.<br><br><div>';
   
    while ($arr =$db->fetch_array($que)) {
    $answer = $db->query("SELECT * FROM mybb_userfields WHERE ufid=".$arr['uid']);

            $tmp = $db->fetch_array($answer);
            $output .= $tmp['fid5']."<br>\n";                                                        
                }
                                         
    $output .= '</div></center></td><td style="width:50%;" class="trow2 page_content">
       <center>Search for a player\'s Adventurer\'s Log.<br><br></center></td>
       </tr>
       <tr colspan="2"><td colspan="2" class="tcat"></td></tr>
       </table></center>';

    eval("\$adLog_home = \"".$templates->get("adLog"). "\";");
    output_page($adLog_home);
}

?>

Sorry to mess you about like this, but I can't test it myself lol.
Pages: 1 2 3