Jump to content

i can get through this code


jkkenzie

Recommended Posts

my code below selects unique countries in my tblcountries table, then uses the country name to get field value called Par_Value. while it loops through, i tried echoing the reusults but i get the same result for each country plus an extra result i cant understand, am sure my code is not arranged properly, help......

 

<?php if (!isset($_COOKIE['loggedin'])) die("You are not logged in!"); ?>
<?PHP
include("phpgraphlib.php");


$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("digitaldevidemt", $con);

$calc1 = mysql_query("SELECT*FROM tblparameter WHERE strName='".$_POST['parameter']."'");
while($rowxx = mysql_fetch_assoc($calc1)){
$val[]= $rowxx['Par_Id'];}
//Get countries
$result = mysql_query("SELECT DISTINCT strCountry FROM tblcountries WHERE Par_Id='".$val[0]."' ORDER BY strCountry");
$intcount=0;
while($row = mysql_fetch_assoc($result))
  {  
  $rows[] = $row['strCountry'];
  $intcount++; 
  }
// Calculate A
$country=0;
//####################################################
while($country<=$intcount)
{
//echo $rows[$country]."<br>";

  $result2 = mysql_query("SELECT*FROM tblcountries WHERE strCountry='".$rows[$country]."' ORDER BY id");
//get sum
                $num=0;
			$intcount2=0;
		    $sum2=0;
			$totalsum=0;
			$num2=0;		  
    // while 2     
	   while($rowsum = mysql_fetch_assoc($result2))
          { 
     ///get Par_Value of the country
      $sum[]=$rowsum['Par_Value'];
	  echo $rowsum['Par_Value']."          ".$sum[$num]."<br>";
          echo $num;
	  
          $num++;	 	                              

          }									
echo $rows[$country]."<br>";
         
$country++;  
}	


?>


 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/104171-i-can-get-through-this-code/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.