- Joined
- Jan 19, 2007
- Posts
- 2,207
- Reaction score
- 47
Need a bit of help with some php and a few kind members helped me in the past.
My code is:
Basically, a field on my table is called names. The information in this field is serialized (so many names are together in a single field, for a single row).
I want to be able to search the whole table (where type='$type' - so many rows) for all names and then show unique names only.
My code above unserializes the names from each field and then lists them, but doesn't deal with any duplicates (which I need removing).
I have looked at functions like "unique_array()", and have tried using it in different places but it isn't doing the job.
Any help appreciated.
My code is:
PHP:
$query = "SELECT names FROM table WHERE type='$type'";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)) {
foreach(unserialize($row['names']) as $key => $value){
echo $value . '<br />';
}
}
Basically, a field on my table is called names. The information in this field is serialized (so many names are together in a single field, for a single row).
I want to be able to search the whole table (where type='$type' - so many rows) for all names and then show unique names only.
My code above unserializes the names from each field and then lists them, but doesn't deal with any duplicates (which I need removing).
I have looked at functions like "unique_array()", and have tried using it in different places but it isn't doing the job.
Any help appreciated.