| Code: |
| $select = mysql_query("SELECT * FROM `users` WHERE `name` = '$username'");
while ($selectn = mysql_fetch_array($select)) { $select123 = str_replace("<", "", $selectn['friendlist']); $friendslist = str_replace(">", "", $select123); $total = mysql_num_rows($select); if($total == 0) { echo "Sorry $username you don't have any friends on your console! Go to the hotel and make some!"; } else { if($total == 1) { $comma = ""; } else if($total > 1) { $comma = ", "; } } echo "$friendslist$comma - $total"; } |
Okay, the above code is supposed to get the users' friends from the Database. It gets the friends, but it doesn't comma them or anything. The friends are stored as:
| Quote: |
| <friendname><nextfriendname><next> |
I have the < and the > removed using $select123 and $friendslist. (Don't ask about the < and >, they must be there.) Okay, so in my database my friend list says:
| Quote: |
| <><1><123> |
The <> starts off the field, it also needs to be there. The first code above displays my friends as so:
| Quote: |
| 1123 - 1 |
(Don't worry about the - 1 thing) I want it to comma the friends, so instead of having the "1123" it would do something such as: "1, 123" if "123" is the last entry in the field then it will not have a comma. It seems that I am unable to do it, because I don't know how to make it separate the friends. (The < and > separates them, but because I have them removed it makes it difficult.)
So, does anybody know how to comma them out? Many thanks.
