Link to home
Create AccountLog in
Avatar of firekiller15
firekiller15

asked on

Doesnt show all the select value on the screen

PHP
I received ouput value that doesnt show all the result i want on the screen

The data output i WANT to received is shown below
supermarketname  | miloAmountstock  |horlickAmountstock| candy.. |chocolate.. | stock..  | chips..
"coles"                   |"21546"                  |"54685"                   |"54658" |"24367"      |"no stock"|"85496"|
"giant"                    |"84564"                  |"87956"                   |"478546"|"45754"    |"no stock"|"78954"|

but the output i get is this
"coles"|"21546"|
"giant"|"54685"|

It looks like it cant read the rest of the data and continue the data in the row of giant 84564
my code is in code snippet


function GetAmount()
{
$ItemID = array(1234,6545,5468,9856,4578,"no stock",4561);
$arrayElement[5] = "no stock";
$supermarketID = array(21,32);
 
 $cnt=count($supermarketID);
 for($x=0; $x<$cnt; $x++)
{
 $supermarketID_value = $supermarketID[$x]; 
 
for ($j = 0; $j < sizeof($ItemID); $j++)
  {
 if (($ItemID[$j] != $arrayElement[5]) 
	{
	 $query = mysql_query("SELECT getitem_std_amountstock( \"$supermarketID_value\",  \"ItemID[$j]\") AS AMOUNT");
     
	 $j = 0; 
         $temp="";
         while($row = mysql_fetch_array($query))
	      {
              $temp .= '"'.$row['AMOUNT'].'"'; 
              }
          $this->GetAmountStockReturn[$i++] .= $temp; 
        }  
	else
        {
      $this->GetAmountStockReturn[$i++] .=  "\"no stock\" |";
  	}
   }
 
 
function joinSUPERMARKETNAMEnAMOUNTSTOCK()
{
//SUPERMARKETNAME select value is from another function
 
 foreach(($this->GetSupermarketReturn_value as $i => $datas)
	 {
           $data1 = "{$datas} | {$this->GetAmountStockReturn[$i]}  "; 
	   print_r( $data1);
	 }
}

Open in new window

Avatar of Xorlev
Xorlev
Flag of United States of America image

Your query seems to only be retrieving a single column.

         $query = mysql_query("SELECT getitem_std_amountstock( \"$supermarketID_value\",  \"ItemID[$j]\") AS AMOUNT");

And:

$temp .= '"'.$row['AMOUNT'].'"';

If you want candy, chocolate, bluechips and what not, you'll need to select them from the database.
Avatar of firekiller15
firekiller15

ASKER

if i output my result in function GetAmount() i can get the result and the result is correct as follow

Array ( [] => "21546" |[1] => "54685" |[2] => "54658" |[3] => "24367" |[4] => "no stock" |[5] => "85496" |[6] => "84564" |[7] => "87956" |[8] => "478546" |[9] => "no stock" |[10] => "78954"

>>If you want candy, chocolate, bluechips and what not, you'll need to select them from the database
i am select them from the database just that im using SQL function.

i dont think i have problem in the first function  GetAmount()
Maybe is because of the join in joinSUPERMARKETNAMEnAMOUNTSTOCK()

Anyone really know pls help
ASKER CERTIFIED SOLUTION
Avatar of Roonaan
Roonaan
Flag of Netherlands image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
yah you are right something worng in $this->GetAmountStockReturn[$i++] .= $temp;
i get rid of increament then everything seems find