$result = mysql_query("SELECT * FROM area ORDER BY date") or die("Error: " . mysql_error());
$parent = array();
while($row = mysql_fetch_assoc($result)){
foreach($row as $value){
$result = explode(",", $value);
foreach($result as $newvalue){
$query="SELECT c_name FROM clients where clients.x='$newvalue'";
and it shows me area name and date correctly but list of clients contains results that are in database but also the ones that are not selected or same as in other row. .
Its several in one column ALUCEL, AGIT, NATIS but i store id's.
So it looks like 453,145,1665 and then i explode that and display names of clients from different table based on those id's. I know its not good solution and database should be normalized but i need it like this for now.
The first thing you are doing wrong is a bad database design. Since it is not normalized you have very little control over data within it and will be guaranteed anomalies throughout every operation you attempt to perform. If you think select is bad, wait until you need to update one of the "child" records since you will now need to select every record in order to do so. You will also end up with exponential growth of the query counts, which isn't a good thing. If you normalize the database and issue a single joined query, than this type of issue will go away.
As for what you have, that is caused by the $parent not being initialized on each iteration, so all you are doing is appending to it within the inner foreach. Simply initialize the $parent = array() at the start of the while.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Yeah, since you only have like 4 posts, if you modify a post that contains a link it will go into moderation queue. It's also a bit of a pain to get it out since we can't use the inline tools to take care of it.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php