Vaupell
01-23-2010, 08:30 PM
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 :confused:
--------------- Added 1264287288 at 1264287288 ---------------
adding code snipittet.. hope it helps to make sence what im trying to do
$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.
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 :confused:
--------------- Added 1264287288 at 1264287288 ---------------
adding code snipittet.. hope it helps to make sence what im trying to do
$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.