This script is taking a lot of time to run and i was wondering if it would be possible to merge the queries into only one
Code:
$query = "SELECT * FROM shop_tshirts WHERE shop_id = '429942'";
$res = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($res)) {
$designid = $row["design_id"];
$articleid = $row["article_id"];
echo "<br>A$articleid = D$designid";
$zquery = "SELECT * FROM shop_tshirts WHERE shop_id = '266497' AND design_id = '$designid'";
$zres = mysql_query($zquery) or die(mysql_error());
while($row = mysql_fetch_array($zres)) {
$categorie = $row["categorie"];
echo " = C$categorie";
$xquery = "UPDATE shop_tshirts SET categorie='$categorie' WHERE article_id='$articleid' AND shop_id='429942'";
$xres = mysql_query($xquery) or die(mysql_error());
echo " .......... UPDATED!";
}
}
The database is used to store a list of t-shirts
"article_id" is the unique identifier of the t-shirt
"design_id" is the ID of the design of the t-shirt
"categorie" is the category
"shop_id" is used for the product types. 429942 is sweatshirts and 266497 are t-shirts
The script is used to find the category ID of each sweatshirts based on the category of the t-shirt with the same design
1st query will find the list of the sweatshirts using shop_id 429942
2nd query will find the category ID by checking what category ID is being used by the t-shirt with the same design
3rd query will update the sweatshirt with the same category ID than the tshirt