PDA

View Full Version : I need some help with pulling data from a table


Parker Clack
01-24-2005, 08:54 PM
I am wanting to take data from my table associate and have it separated by a comma between each entry.

I have the following:


$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

sabret00the
01-24-2005, 09:21 PM
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"?

Jolten
01-24-2005, 09:28 PM
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') . '";');

sabret00the
01-24-2005, 09:38 PM
assuming he wasn't just needing to implode the array
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 :)

Jolten
01-24-2005, 09:39 PM
Pretty much the same :) I left out the comma because that could be added to the associate_names template

sabret00the
01-24-2005, 10:04 PM
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 :)

Parker Clack
01-24-2005, 11:13 PM
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

$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

Jolten
01-24-2005, 11:51 PM
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;

Parker Clack
01-25-2005, 11:20 AM
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.

Dean C
01-25-2005, 02:15 PM
Parker, just a tip, surround your code with [ php ] [ /php ] tags for clarity, makes it easier for people to read and thefore help :)