異なる MYSQL テーブルに 2 セットの配列があります。これがやりたいこと
What I Want TO Do
TABLE_ONE connect to the table.
get the value we want from session_id
THEN get the array associated with the value (session_id)
explode the array to get individual values.
NOW::::: - GO TO TABLE_TWO
TABLE_TWO Go straight to the first value from array (TABLE_ONE)
Explode the array associated with it.
Delete the number that's equal to the session_id
_____________________________________________________
And so fort....
以下のより視覚的な説明:
session_id = 4
TABLE_ONE:
id array1
1 4
2 1
3 2,5
4 1,3,4,5
5 4,5
TABLE_TWO:
id array2
1 4,6,9,2
2 3,7,8,2
3 7,12,4,9
4 1,5,4,8
5 3,6,12,3,5,4
というわけで、session_id = 4TABLE_ONE に移動しますid 4。id-4 の配列は 1,3,4,5 です。これで 4 が見つかることがわかりました。ここで、 id 1,3,4,5 of TABLE_TWO
TABLE_TWO の配列を分解4し、そこから配列を削除する必要があります。配列を内破し、新しい値をデータベースに保存します。
これは私が行ったことです-id-3から「4」のみを削除し、id-4のすべての値を削除します。助けてください!!
$SESSION = 4;
$depSQL = mysql_query("SELECT array1 FROM TABLE_ONE WHERE id='$SESSION' LIMIT 1");
while($row=mysql_fetch_array($depSQL)) { $depARRAY = $row["array1"]; }
$explodedDEP = explode(",", $depARRAY);
foreach ($explodedDEP as $key1 => $value1) {
$stSQL = mysql_query("SELECT array2 FROM TABLE_TWO WHERE id='$value1'");
while($get=mysql_fetch_array($stSQL)) { $stARRAY = $get["array2"];}
$explodedST = explode(",", $stARRAY);
foreach ($explodedST as $key2 => $value2) {
if ($value2 == $SESSION) {
unset($explodedST[$key2]);
}
}
$newST = implode(",", $explodedST);
$sql = mysql_query("UPDATE TABLE_TWO SET array2 ='$newST' WHERE id='$value2'");
}
exit();
助けてください!!!私はそれに本当に苦労しています。何時間も試してみましたが、実際にはどこにも行きませんでした。問題はデータベースへの挿入にあると思います。助けてください。