Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-06-2002, 03:42 PM
Bald Bouncer's Avatar
Bald Bouncer Bald Bouncer is offline
 
Join Date: Oct 2001
Location: UK
Posts: 228
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default problem driving me mad

PHP Code:
  $users=$DB_site->query("SELECT userid,username,usertitle FROM user WHERE username LIKE '%".addslashes(htmlspecialchars($findname))."%' ORDER BY username");
  
$field=$DB_site->query("SELECT field14 FROM userfields WHERE userid=$users[userid]");
  echo 
"<table>";
  if (
$DB_site->num_rows($users)>0) {
    echo 
"<tr><td nowrap><p><b>Team Members Found:</b></p></td>".iif($perms[ismoderator] or $bbuserinfo['usergroupid']==25"<td nowrap><p>&nbsp;</p></td>""").iif($perms[ismoderator] or $bbuserinfo['usergroupid']==25"<td nowrap><p>&nbsp;</p></td>""")."</tr>\n";
    while (
$user=$DB_site->fetch_array($users)) {
      echo 
"<tr><td nowrap><p>$user[username] - $field[field14]</p></td>".iif($perms[ismoderator] or $bbuserinfo['usergroupid']==25"<td nowrap><a href=\"user.php?action=viewuser&userid=$user[userid]\"><p>[view user]</a> <a href=\"user.php?action=edituser&userid=$user[userid]\">[Edit User]</a></p></td>""")."</tr>\n";
    } 
can anyone fix this code so it will show the contents of profile field 14 next to the username....I think it needs to fetch the rray of $users and $field but Im not sure how its done

any help appreciated
Reply With Quote
  #2  
Old 04-07-2002, 10:50 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can join the user and userfield tables right in the first query:
Code:
$users = $DB_site->query("
	SELECT userid,username,usertitle,field14
	FROM user
	WHERE username LIKE '%".addslashes(htmlspecialchars($findname))."%'
	ORDER BY username
");

echo "<table>";
if ($DB_site->num_rows($users)>0) {
	echo "<tr><td nowrap><p><b>Team Members Found:</b></p></td>".iif($perms[ismoderator] or $bbuserinfo['usergroupid']==25, "<td nowrap><p>&nbsp;</p></td>", "").iif($perms[ismoderator] or $bbuserinfo['usergroupid']==25, "<td nowrap><p>&nbsp;</p></td>", "")."</tr>\n";
	while ($user=$DB_site->fetch_array($users)) {
		echo "<tr><td nowrap><p>$user[username] - $field[field14]</p></td>".iif($perms[ismoderator] or $bbuserinfo['usergroupid']==25, "<td nowrap><a href=\"user.php?action=viewuser&userid=$user[userid]\"><p>[view user]</a> <a href=\"user.php?action=edituser&userid=$user[userid]\">[Edit User]</a></p></td>", "")."</tr>\n";
	}
}
echo "</table>";
You also have this code twice in there, not sure it's supposed to be there (and if it is, use only one iif()):
Code:
iif($perms[ismoderator] or $bbuserinfo['usergroupid']==25, "<td nowrap><p>&nbsp;</p></td>", "")
Reply With Quote
  #3  
Old 04-07-2002, 06:38 PM
Bald Bouncer's Avatar
Bald Bouncer Bald Bouncer is offline
 
Join Date: Oct 2001
Location: UK
Posts: 228
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

it will need to pull field14 from userfield not users i think....so how exactly do I use join to stick both the coloms in the same query mate?

PHP Code:
$users $DB_site->query(
SELECT userid,username,usertitle
FROM user 
WHERE username LIKE '%"
.addslashes(htmlspecialchars($findname))."%' 
ORDER BY username 
"
); 
I need to grab field14 from userfield in the above :dead:
Reply With Quote
  #4  
Old 04-07-2002, 06:46 PM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Of course I forgot the JOIN line... duh.
Code:
$users = $DB_site->query("
	SELECT userid,username,usertitle,field14
	FROM user
	LEFT JOIN userfield USING (userid)
	WHERE username LIKE '%".addslashes(htmlspecialchars($findname))."%'
	ORDER BY username
");
Reply With Quote
  #5  
Old 04-07-2002, 07:13 PM
Bald Bouncer's Avatar
Bald Bouncer Bald Bouncer is offline
 
Join Date: Oct 2001
Location: UK
Posts: 228
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

cheers for the help mate but its still not working dont happen to know were its going wrong do you mate?

PHP Code:
$users $DB_site->query("SELECT userid,username,usertitle,field14 FROM user LEFT JOIN userfield USING (userid) WHERE username LIKE '%".addslashes(htmlspecialchars($findname))."%' ORDER BY username");
  echo 
"<table>";
  if (
$DB_site->num_rows($users)>0) {
    echo 
"<tr><td nowrap><p><b>Team Members Found:</b></p></td>".iif($perms[ismoderator] or $bbuserinfo['usergroupid']==25"<td nowrap><p>&nbsp;</p></td>""").iif($perms[ismoderator] or $bbuserinfo['usergroupid']==25"<td nowrap><p>&nbsp;</p></td>""")."</tr>\n";
    while (
$user=$DB_site->fetch_array($users)) {
      echo 
"<tr><td nowrap><p>$user[username] - $user[field14]</p></td>".iif($perms[ismoderator] or $bbuserinfo['usergroupid']==25"<td nowrap><p>EDIT USER</p></td>""")."</tr>\n";
    }
  } else {
    echo 
"<td><p>No Team Members found</p></td>";
  }
  echo 
"</table>";

Reply With Quote
  #6  
Old 04-07-2002, 07:20 PM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok replace "SELECT userid" with "SELECT user.userid".
Reply With Quote
  #7  
Old 04-07-2002, 07:39 PM
Bald Bouncer's Avatar
Bald Bouncer Bald Bouncer is offline
 
Join Date: Oct 2001
Location: UK
Posts: 228
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks a lot mate worked a charm!!
really appreciated!!

:bunny:
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:24 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04034 seconds
  • Memory Usage 2,247KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete