|
Posted by matthud on 02/17/07 04:33
//GET INSERTED CHUNK ID
$getid = mysql_query("SELECT id FROM chunks WHERE chunk = '$chunk'");
$idrow = mysql_fetch_array($getid, MYSQL_ASSOC);
$chunkid = $idrow["id"].",";
$eachtag = explode(",", $tags);
foreach($eachtag as $key=>$value) {
For some reason, this code:
$updated = $row["chunks"] . $chunkid;
mysql_query("UPDATE tagtochunk SET chunks = '$updated' WHERE tag =
'$value'");
only updates the field with $chunkid, leaving out row["chunks"]. I'm
guessing it may have something to do with scope within control
structures.... I'm at a loss.
$query = "SELECT chunks FROM tagtochunk WHERE tag = '$value'";
$result = mysql_query($query);
if (mysql_num_rows($result) == 0) {
//CREATE NEW TAG ENTRY
mysql_query("INSERT INTO tagtochunk (tag, chunks) VALUES ('$value',
'$chunkid')");
} else {
//UPDATE CUR TAG WITH NEW CHUNKID
$updated = $row["chunks"].$chunkid;
mysql_query("UPDATE tagtochunk SET chunks = '$updated' WHERE tag =
'$value'");
}
}
mysql_close($con);
?>
Navigation:
[Reply to this message]
|