loop inside loop help plese

hello
forgive me about my bad english
im trying to save tag cloud into the database and here is my code
[php]$query06 = “select * from tag_cloud”;
$result06 = @mysql_query ($query06,$config);
while($dbtag = mysql_fetch_array($result06)){
$tc_value = $dbtag[“tc_value”];
$tc_count = $dbtag[“tc_count”];
$tcpiece = explode(" ", $post);
for($i = 0; $i < count($tcpiece); $i++){
$tag = $tcpiece[$i];
if($tag == $tc_value){
$query07 = “update tag_cloud set tc_count= tc_count+1 where tc_value = ‘$tag’”;
$result07 = @mysql_query ($query07,$config);
}else{
$query08 = “insert into tag_cloud (tc_value, tc_count) values (’$tag’,‘1’)”;
$result08 = @mysql_query ($query08,$config);
}
}
}[/php]

this code working good only when the tag word already exist but if it new it will be inserted many times
could some one solve this problem please
thanks for advance

i also try this but it gives me error in line 5(query06 =…)
[php]$post=“Digital Film me and her”;
$tcpiece = explode(" ", $post);
for($i = 0; $i < count($tcpiece); $i++){
$tag = $tcpiece[$i];
query06 = “select * from tag_cloud where tc_value = $tag”;
$result06 = @mysql_query ($query06,$config)or die(mysql_error());
if($result06){
$query07 = “update tag_cloud set tc_count= tc_count+1 where tc_value = ‘$tag’”;
$result07 = @mysql_query ($query07,$config)or die(mysql_error());
}else{
$query08 = “insert into tag_cloud (tc_value, tc_count) values (’$tag’,‘1’)”;
$result08 = @mysql_query ($query08,$config)or die(mysql_error());
}
}
[/php]
any help???

i solve the error but its still not working specially with the 2nd condition of (if)
i mean if the word is not found in database it not make new record for it
[php]$post=“me and her”;
$tcpiece = explode(" ", $post);
for($i = 0; $i < count($tcpiece); $i++){
$tag = $tcpiece[$i];
$query06 = “select * from tag_cloud where tc_value = ‘$tag’”;
$result06 = @mysql_query ($query06,$config);
if($result06){
$query07 = “update tag_cloud set tc_count= tc_count+1 where tc_value = ‘$tag’”;
$result07 = @mysql_query ($query07,$config)or die(mysql_error());
}else{
$query08 = “insert into tag_cloud (tc_value, tc_count) values (’$tag’, ‘1’)”;
$result08 = @mysql_query ($query08,$config);
}
}[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service