Jump to content

Storing a value(CONCAT) seperated by a comma, then getting data


slyte33

Recommended Posts

Ok so take a look at this:

 

$playersquery=$db->execute("select * from all_players");
$players=$playersquery->fetchrow();
$members=explode(",",$players['all_player_names']);
$size=count($members);

for($i=0;$i<=$size;$i++) {
$user[$i] = $db->GetOne("select name from players where id=$members[$i]");
echo $user[$i][name];
echo "<br>";
}

 

Let's say I have a 'all_players' table with the field 'all_player_names'(text)

And let's also say that 'all_player_names' has this in it:

1,2,3

 

Then in the 'players' table there would be this:

ID|NAME
1|Jamie
2|Stephanie
3|Alex

 

So if 'all_player_names' has '1,2,3' in it, the top code above should display:

Jamie

Stephanie

Alex

 

... but theres a problem. It only displays the first letter's of their names. So the output of it is this:

J
S
A

 

I'm pretty sure I had it right when I made it, but I still can't seem to find out why only 1 letter of the string is displayed. All help would be much much appreciated and I hope I explained what I am trying to do pretty well :)

Thanks!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.