Hi guys,
What I have is a tree link relationship between users on my site. It is kind of like a pyramid scheme in that if someone joins "under" you, when they get a daily update, you get 20% of their daily update.
I have a MySQL statement to this effect:
- UPDATE users SET value=(value*factor+value)
Now to update receruiters (superior) could I have something like:
- $rows = mysql_query("SELECT name, superior, value, factor FROM users");
-
-
while ($rows) {
-
$row = msql_fetch_array($rows);
-
$name = $row['name'];
-
$superior = $row['superior'];
-
$new_value = $row['value'] * $row['factor'] + $row['value'];
-
$sups_value = $new_value * 0.2;
-
mysql_query("UPDATE users SET value='$new_value' WHERE name=$name");
-
mysql_query("UPDATE users SET value='$sups_value' WHERE name=$superior");
-
}
However the problem is this means that there will be two UPDATEs for every row found and I was wondering if there is an easier way that anyone knows of?