View file sad/garden/zvv/sad.php

File size: 1.07Kb
<?php
/**********************************
*	@year: 2018				      *
*	@author: Klubv	              *
*   @icq: 611940693			      *
*	@link: http://baz23.ru        *
**********************************/
$dbhost = "localhost";
$dbuser = "sad";
$dbpass = "sad";
$dbname = "sad";



mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($dbname);



function doxod ($id) {

$tree = mysql_fetch_array(mysql_query("SELECT * FROM `tree` WHERE `id` = '".$id."'"));

if ($tree['level'] == 1)

return 1;

if ($tree['level'] == 2)

return 3;

if ($tree['level'] == 3)

return 9;

if ($tree['level'] == 4)

return 18;

if ($tree['level'] == 5)

return 30;

if ($tree['level'] == 6)

return 45;

if ($tree['level'] == 7)

return 63;

if ($tree['level'] == 8)

return 84;

if ($tree['level'] == 9)

return 108;

if ($tree['level'] == 10) {

return 135;

} else {

}

}



$sql = mysql_query("SELECT * FROM `tree`");

while ($tree = mysql_fetch_array($sql)) {

$result = $tree['fruit'] + doxod($tree['id']);

mysql_query("UPDATE `tree` SET `fruit` = '".$result."' WHERE `id` = '".$tree['id']."'");  

}

?>