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

Reply
 
Thread Tools Display Modes
  #1  
Old 01-23-2010, 08:30 PM
Vaupell's Avatar
Vaupell Vaupell is offline
 
Join Date: Apr 2008
Location: Esbjerg, Denmark
Posts: 1,036
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default seeking php help, foreach with destinct selection [ sorted ]

got a table similar to this, just much larger
colum = autoinc for table
columa and columb = unknown data
columc is known data i can select with.

But if i just SELECT * FROM my table WHERE columc=knownvalue
the result will be an array i also need to run through a loop to display

im going to print/echo via templates, <tables> and the template_bit
ill be using will be something like
<tr><td>{vb:raw DataG}</td><td>{vb:raw DataX}

colum|columa|columb|columc
-------+--------+--------+-------
idfield| data1| dataG | data3
idfield| data1| dataF | data2
idfield| data1| dataH | data1
idfield| data2| dataG | data3
idfield| data2| dataF | data2
idfield| data2| dataH | data1
-------------------------------------

Now i want to display DataG from both places (or many more) where DataG is present
but only once pr unique columA

so first i get the unique columa's with sql

$getunique = $vbulletin->db->query("SELECT DISTINCT columa FROM ".TABLE_PREFIX."mytable");

and now im stuck,,
so im thinking maybe assign each unique id's with a id and then
run a loop that collects the data for display

forach ($getunique, ??what value??)
{
-- run the templater registers and renders..
}

i hope its clear what im trying to do

--------------- Added [DATE]1264287288[/DATE] at [TIME]1264287288[/TIME] ---------------

adding code snipittet.. hope it helps to make sence what im trying to do

PHP Code:
$getapplicants $vbulletin->db->query_read("SELECT DISTINCT userid FROM "TABLE_PREFIX ."ewapplication");
while(
$row=$vbulletin->db->fetch_array($getapplicants))
{
 
$geta1=$vbphrase[ewow_app_main_name];
 
$getcharname=$vbulletin->db->query("SELECT * FROM ".TABLE_PREFIX."ewapplication WHERE question='".$geta1."'");
 
$loadcharname $db->fetch_array($getcharname);
 
$charactername $loadcharname['ansver'];

  
$templater vB_Template::create('ew_applicant_list_bit');
  
$templater->register('charname'$charactername);
  
$applicantbit .= $templater->render();

result :

character name :
testcharlie
testcharlie

but the second user, should have been testjohn
and if more was added then ofcourse they should appear.
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 05:56 PM.


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.03714 seconds
  • Memory Usage 2,210KB
  • 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)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)showthread_list
  • (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_threadedmode.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_threaded
  • showthread_threaded_construct_link
  • 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