By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,188 Members | 832 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,188 IT Pros & Developers. It's quick & easy.

how to get particular id from mysql db

P: 10
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3.     $result = mysql_query("SELECT user_id,cb_parentid FROM comprofiler ");
  4.     while($row = mysql_fetch_array($result))
  5.     {    
  6.      echo "<td>" . $row['cb_parentid'] . "</td>\n <br/>";    
  7.  
  8.     }    
  9. ?>
i want calculation on particular parent_id but there is problem how can i take particular parent if form while loop. if any one can suggest me how can is possible.
Dec 31 '11 #1
Share this Question
Share on Google+
1 Reply


P: 10
Expand|Select|Wrap|Line Numbers
  1. function earning($user_id1)
  2. {
  3.     $income=0;
  4.     $sql_earn="SELECT * FROM jos_comprofiler where cb_parentid='".$user_id1."'";
  5.     $result_earn = mysql_query($sql_earn);
  6.     while($row_earn = mysql_fetch_array($result_earn))
  7.     {
  8.         if($row_earn['cb_package']=='Basic Details Rupees 3400')
  9.         {
  10.             echo $income+=(3400/100)*25; echo "<hr>";
  11.         }
  12.         else if($row_earn['cb_package']=='Advance Details Rupees 6100')
  13.         {
  14.             echo $income+=(6100/100)*25; echo "<hr>";
  15.         }
  16.         //--------------------------//Level 2-------------------------
  17.         $sql_earn1="SELECT * FROM jos_comprofiler where cb_parentid='".$row_earn['user_id']."'";
  18.         $result_earn1 = mysql_query($sql_earn1);
  19.         while($row_earn1 = mysql_fetch_array($result_earn1))
  20.         {
  21.             if($row_earn1['cb_package']=='Basic Details Rupees 3400')
  22.             {
  23.                 echo $income+=(3400/100)*25; echo "<hr>";
  24.             }
  25.             else if($row_earn1['cb_package']=='Advance Details Rupees 6100')
  26.             {
  27.                 echo $income+=(6100/100)*25; echo "<hr>";
  28.             }
  29.         }
  30.         //--------------------------//Level 2-------------------------
  31.     }
  32.     echo $income;
  33. }


here we mention

Expand|Select|Wrap|Line Numbers
  1. <div><?php echo "Earning: ".earning($row0->user_id); ?></div>
Dec 31 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.