I have a table with 3 fields: id, product_id and subcategort_id
I have repeated data in that table. I wrote the code below to delete the repeated data
but I got this error:
Fatal error: Maximum execution time of 60 seconds exceeded in G:\programs\xamp\xampp\htdocs\carat\test.php on line 9
could you please have a look at the code and suggest how I can avoid this error and do what I need?
this is the code:
Code: Select all
<?php
include 'connect.php';
$wasbefore=mysql_query("SELECT * FROM prod_subcat ")or die(mysql_error());
$wasbeforenum=mysql_num_rows($wasbefore);
echo $wasbeforenum;
$id=0;
while($wasbeforenum-$id){
$wasbefore=mysql_query("SELECT * FROM prod_subcat WHERE id='$id' ")or die(mysql_error());
$row=mysql_fetch_array($wasbefore);
$prod=$row['productID'];
$sub=$row['subcategoryID'];
$wasbefore=mysql_query("SELECT * FROM prod_subcat WHERE subcategoryID='$sub' AND productID='$prod' ")or die(mysql_error());
$wasbeforenum=mysql_num_rows($wasbefore);
if($wasbeforenum>1){
mysql_query("DELETE FROM `prod_subcat` WHERE `id`='$id' ") or die(mysql_error());
}
$id++;
}
?>