UrbanTwitch Posted August 5, 2009 Share Posted August 5, 2009 Hi, I'm trying to add what the $total_overall_cookies variable would be. Here is an image to better explain myself. I want to add the Total Cookies on the right and present it somewhere near the bottom. The $totalcookies variable is displayed inside the while loop full page php: http://www.rmb.pastebin.com/d28d8111b is there any way to add the $total_cookie variable in every while loop made? Thanks. Link to comment https://forums.phpfreaks.com/topic/168974-solved-adding-a-while-var/ Share on other sites More sharing options...
mikesta707 Posted August 5, 2009 Share Posted August 5, 2009 i don't quite understand your question, but try $total = 0; while ($list = mysql_fetch_array($result)) { if($ref_mem['ref_valid'] == 'yes') { $acookie = "10"; }else{ $acookie = "0"; } if($ref_mem['ref_login'] == 'yes') { $bcookie = "5"; }else{ $bcookie = "0"; } if($ref_mem['ref_topic'] == 'yes') { $ccookie = "10"; }else{ $ccookie = "0"; } if($ref_mem['ref_ncomment'] == 'yes') { $dcookie = "5"; }else{ $dcookie = "0"; } if($ref_mem['ref_profile'] == 'yes') { $ecookie = "5"; }else{ $ecookie = "0"; } if($ref_mem['ref_avatar'] == 'yes') { $fcookie = "5"; }else{ $fcookie = "0"; } if($ref_mem['ref_tencookies'] == 'yes') { $gcookie = "10"; }else{ $gcookie = "0"; } if($ref_mem['ref_ref'] == 'yes') { $hcookie = "20"; }else{ $hcookie = "0"; } $total_cookies = $acookie+$bcookie+$ccookie+$dcookie+$ecookie+$fcookie+$gcookie+$hcookie+10; $total += total_cookies; ... Link to comment https://forums.phpfreaks.com/topic/168974-solved-adding-a-while-var/#findComment-891531 Share on other sites More sharing options...
UrbanTwitch Posted August 5, 2009 Author Share Posted August 5, 2009 Thanks! I just had to put the += $total_cookeis INSIDE the loop Link to comment https://forums.phpfreaks.com/topic/168974-solved-adding-a-while-var/#findComment-891532 Share on other sites More sharing options...
flyhoney Posted August 5, 2009 Share Posted August 5, 2009 I would so something like this: <?php $cookie_values = array( 'ref_valid' => 10 'ref_login' => 5 'ref_topic' => 10 'ref_ncomment' => 5 'ref_profile' => 5 'ref_avatar' => 5 'ref_tencookies' => 10 'ref_ref' => 20 ); $cookies = array(); $total = 0; while ($list = mysql_fetch_array($result)) { $get_teh_datawee = mysql_query("SELECT * FROM `members` WHERE `id` = '$list[referral_id]'"); $ref_mem = mysql_fetch_array($get_teh_datawee); foreach ($ref_mem as $key => $value) { if ($value == "yes") { $cookies[$key] = $cookie_values[$key]; $total += $cookie_values[$key]; } else { $cookies[$key] = 0; } } } print_r($cookies); Link to comment https://forums.phpfreaks.com/topic/168974-solved-adding-a-while-var/#findComment-891535 Share on other sites More sharing options...
UrbanTwitch Posted August 5, 2009 Author Share Posted August 5, 2009 flyhonee, I accidentally forgot to put the += $total_cookeis inside the loop which is WHY it didn't work. However, your work is very thorough and very appreciated. Link to comment https://forums.phpfreaks.com/topic/168974-solved-adding-a-while-var/#findComment-891537 Share on other sites More sharing options...
mikesta707 Posted August 5, 2009 Share Posted August 5, 2009 no prob, make sure you set the topic as solved! Link to comment https://forums.phpfreaks.com/topic/168974-solved-adding-a-while-var/#findComment-891542 Share on other sites More sharing options...
UrbanTwitch Posted August 5, 2009 Author Share Posted August 5, 2009 It won't let me modify my topic post. Link to comment https://forums.phpfreaks.com/topic/168974-solved-adding-a-while-var/#findComment-891546 Share on other sites More sharing options...
_DarkLink_ Posted August 5, 2009 Share Posted August 5, 2009 You just need to click on that little "Topic Solved" button at the bottom left side of this page. Link to comment https://forums.phpfreaks.com/topic/168974-solved-adding-a-while-var/#findComment-891551 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.