0

hello...

i am doing authors page. in this i want to display related authors of that site. in authors table author has a field author type. he can give more types by ',' separate.

so i want to dispaly related authors who has matched his type.

here i wrote my code but displaying many times.
example:
main author type:blues,reds.

another author type reds,greens,blues.

then i am extracting and next using foreachloop like this

$select=mysql_query("select * from authors where id!=$_SESSION[author_id]");
while($fetch=mysql_fetch_array[$select])
{
foreach($mainauthortype as $mauthortype)
{
foreach($fetch[anotherauthortype] as $aauthortype)
{
if(mauthortype==aauthortype)
{
displaying related authors. here displayig same author moretimes. so how can i restrict this.
}
}
}
}
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by pritaeas
0

MySQL has the FIND_IN_SET() function, which allows you to search for a value in a column that has a CSV string.

SELECT * FROM authors WHERE FIND_IN_SET('reds', type)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.