How to credit a user according to the level the user he referred is on in Php and Mysql Query? -


i have working code credits user when referred another. trying credit user according level user referred on, code use faulty , not credit correctly, please @ code , tell me think wrong;

$credit_referred=mysql_query("select * all_users credited=0 , referer='$user'") or die(mysql_error()); while ($row = mysql_fetch_assoc($credit_referred)) {      echo $row["level"];      $refered_level = $row["level"];  } $num=mysql_num_rows($credit_referred); if($referlevelpart==1) {     $creditedpoints = $num * 10; } elseif($refered_level==2) {     $creditedpoints = $num * 20;  } elseif($refered_level==3) {     $creditedpoints = $num * 50;  } elseif($refered_level==4) {     $creditedpoints = $num * 100;  } else {     $creditedpoints = 0;     }  $creditquery="update all_users set points=points+$creditedpoints username='$user'"; $creditqueryresult=mysql_query($creditquery) or die(mysql_error()); $markcreditedquery="update all_users set credited=1 credited=0 , referer='$user'"; $markcreditedqueryresult=mysql_query($markcreditedquery) or die(mysql_error()); $credited_points = user_info($user, points); 

the problem credit same amount referred user detected fetch_assoc, please need here. thanks


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -