Jump to content

[SOLVED] Adding a while $var


UrbanTwitch

Recommended Posts

Hi, I'm trying to add what the $total_overall_cookies variable would be. Here is an image to better explain myself.

 

kc1d8n.jpg

 

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.