Hi, I am trying to create a script which checks the "users_theme" table and finds all the user_id's which exist in this table and not the "users" table. Once I have those id's, I want to run a foreach loop to delete all rows with that user id from the database.
I did a script where it checks the "users" table and finds all the user_id's which exist in this table and not the "users_theme" table and add it. But I can't seem to create a script which checks the "users_theme" table and finds all the user_id's which exist in this table and not the "users" table. Once I have those id's, I want to run a foreach loop to delete all rows with that user id from the database.
$query="select * from users";
$rs=mysql_query($query)or die("error in sql query".mysql_error());
while($row=mysql_fetch_array($rs,MYSQL_BOTH))
{
$query_add="select * from users_theme where user_id=".$row;
$rs_add=mysql_query($query_add)or die("error in sql query.".mysql_error());
$row_num=mysql_num_rows($rs_add);
if($row_num==0):
$query_ins="insert into users_theme(user_id)values('".$row."')";
$rs_ins=mysql_query($query_ins)or die("error in sql query.".mysql_error());
endif;
}
?>