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 01-24-2005, 08:54 PM
Parker Clack Parker Clack is offline
 
Join Date: Oct 2001
Posts: 351
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default I need some help with pulling data from a table

I am wanting to take data from my table associate and have it separated by a comma between each entry.

I have the following:

PHP Code:
$associategroups=$DB_site->query("SELECT * FROM associate ORDER BY id DESC");

while (
$rows=$DB_site->fetch_array($associategroups)) {
$ass_groupurl=$rows['associateurl'];
$ass_group=$rows['associate'];
eval(
"\$associatenames = \"".gettemplate("associate_names")."\";");
}

eval(
"\$associate = \"".gettemplate('associate')."\";");

I have a template called $associatenames with the following:

<
a href="$ass_groupurl">$ass_group</a>

and 
a template called $associate with:

<
table cellpadding="4" cellspacing="0" border="1" width="80%" align="center" bordercolor="black">
<
tr bgcolor="#ededef"><td>
<
smallfont>$associatenames</smallfont>
</
td></tr></table
Right now as I have it written I am getting on one of the entries listed. How do I set this up so I get something like

entry1,entry2,.....


Thanks,
Parker
Reply With Quote
  #2  
Old 01-24-2005, 09:21 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

so let me guess this right, you have a colum which has the data as "john jane jack jude july" and you want it to read "john, jane, jack, jude, july"?
Reply With Quote
  #3  
Old 01-24-2005, 09:28 PM
Jolten Jolten is offline
 
Join Date: Mar 2004
Posts: 749
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

while ($rows=$DB_site->fetch_array($associategroups)) {
$ass_groupurl=$rows->associateurl;
$ass_group=$rows->associate;
eval('$associatenames .= "' . fetch_template('associate_names') . '";');
$col++;
}
eval('$associate .= "' . fetch_template('associate') . '";');
Reply With Quote
  #4  
Old 01-24-2005, 09:38 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

assuming he wasn't just needing to implode the array
PHP Code:
while ($rows=$DB_site->fetch_array($associategroups)) {
$ass_groupurl=$rows->associateurl;
$ass_group=$rows->associate;
eval(
'$associatenames .= "' fetch_template('associate_names') . '";');
$associatenames .= ", ";

$col++;
}
eval(
'$associate .= "' fetch_template('associate') . '";'); 
he'll need to do the comma
Reply With Quote
  #5  
Old 01-24-2005, 09:39 PM
Jolten Jolten is offline
 
Join Date: Mar 2004
Posts: 749
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Pretty much the same I left out the comma because that could be added to the associate_names template
Reply With Quote
  #6  
Old 01-24-2005, 10:04 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Jolten
Pretty much the same I left out the comma because that could be added to the associate_names template
it's all your code i just added a line lol
Reply With Quote
  #7  
Old 01-24-2005, 11:13 PM
Parker Clack Parker Clack is offline
 
Join Date: Oct 2001
Posts: 351
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for all the help. But (and yes I know its antique) I am still using vbulletin 2.36. fetch_template does not exist in 2.36. Any other suggestions?

This is what I have and it only displays

PHP Code:
$associategroups=$DB_site->query("SELECT * FROM associate ORDER BY id DESC");

while (
$rows=$DB_site->fetch_array($associategroups)) {
$ass_groupurl=$rows['associateurl'];
$ass_group=$rows['associate'];
eval(
"\$associatenames = \"".gettemplate("associate_names")."\";");
$associatenames .= ", ";
$col++; 
}
eval(
"\$associate = \"".gettemplate('associate')."\";"); 
item,

and then nothing after the comma.

Thanks,
Parker
Reply With Quote
  #8  
Old 01-24-2005, 11:51 PM
Jolten Jolten is offline
 
Join Date: Mar 2004
Posts: 749
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

oooooooo v2.36 well.. I don't know 2.36 but try changing:

$ass_groupurl=$rows['associateurl'];
$ass_group=$rows['associate'];

to

$ass_groupurl=$rows->associateurl;
$ass_group=$rows->associate;
Reply With Quote
  #9  
Old 01-25-2005, 11:20 AM
Parker Clack Parker Clack is offline
 
Join Date: Oct 2001
Posts: 351
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Jolten:

That is what I used the first time and that didn't work either. In other words I have used $rows['associateurl'] and $rows->associateurl and neither one produces other than one result.
Reply With Quote
  #10  
Old 01-25-2005, 02:15 PM
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Location: England
Posts: 9,071
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Parker, just a tip, surround your code with [ php ] [ /php ] tags for clarity, makes it easier for people to read and thefore help
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 02:42 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04441 seconds
  • Memory Usage 2,265KB
  • 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_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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