943,741 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 8015
  • PHP RSS
May 31st, 2009
0

delete or clear array??

Expand Post »
Hi,

I want to clear or delete old values of array
I attached my database dump with this post
my code is
require_once('includes/DbConnector.php');
require_once('includes/Validator.php');
require_once('includes/CommonUtility.php');
$z=0;
$duplicateFlag=false;
$qury="SELECT orders.order_id,users.company,users.minorderamt,vendororder.vendid   
	   FROM orders 
	   LEFT JOIN vendororder ON  vendororder.orderid=orders.order_id
	   LEFT JOIN users ON  users.user_id=vendororder.vendid  
	   WHERE orders.status='C' AND orders.order_id='368'
	   ORDER BY vendororder.vendid";   
$qryR1=$connector->query($qury); 
while($rsV=$connector->fetchArray($qryR1)){
$total=0; 
$minAmt[]=$rsV['minorderamt'];
$l=0;
 
echo '<TABLE width="100%"  border=0 align=center cellPadding=3 cellSpacing=1 bgColor="#EAEAEA">
	  <TBODY>
	   <TR bgcolor="#FFFFFF">  
		<TD align=left height="55px" colspan=4  class="text13">'.($z+1).' )&nbsp;&nbsp;<B>Vendor:&nbsp;&nbsp;&nbsp;&nbsp;'.$rsV['company'].'</B> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Min Order Amount:<B>&nbsp;$&nbsp;'.sprintf("%1.2f",$rsV['minorderamt']).'</B></TD> 
	  </TR> 
	  <TR bgcolor="#FFFFFF">  
		<TD align=center height="35px"  class="text13"><B>Product</B></TD><TD align=center  height="35px" class="text13"><B>Quantity</B></TD>
		<TD align=center height="35px"  class="text13"><B>Bid Price</B></TD><TD align=center  height="35px" class="text13"><B>Total Amount( $ )</B></TD>
	  </TR>';
         $qry="SELECT bids.bid_id,vendid,orderid,bidamount,status,biddetails.pid,biddetails.qty,biddetails.bidprice,bidprice,product.item_desc,product.product_id
	           FROM biddetails 
			   LEFT JOIN product ON  product.product_id=biddetails.pid
			   LEFT JOIN bids ON  bids.bid_id=biddetails.bid_id 
			   WHERE bids.orderid='".$rsV['order_id']."' AND bids.vendid='".$rsV['vendid']."'  GROUP BY product.product_id 
			   ORDER BY bids.orderid";   
		$qryRslt=$connector->query($qry); echo "<BR> TOTCOUUNT".$numrow=$connector->fnGetNumRows($qryRslt);
		$pp=0;
		while($rs_B=$connector->fetchArray($qryRslt)){
				echo '<TR bgcolor="#FFFFFF">  
						<TD align=center height="35px"  class="text13">'.$rs_B['item_desc'].'</TD><TD align=center  height="35px" class="text13">'.$rs_B['qty'].'</TD>
						<TD align=center height="35px"  class="text13">'.$rs_B['bidprice'].'</TD><TD align=center  height="35px" class="text13">'.(sprintf("%1.2f",$rs_B['bidprice']*$rs_B['qty'])).'</TD>
					  </TR>';

//Here i added all total and vendor id  in array  $indTot[] and  $indVid[] respectively					
			
			  $total=$total+($rs_B['bidprice']*$rs_B['qty']);	 //echo  $rs_B['bidprice']*$rs_B['qty']."<BR>";
			  $indTot[]=($rs_B['bidprice']*$rs_B['qty']);
			  $indVid[]=$rs_B['vendid'];  
			  $indPid[]=$rs_B['product_id'];
			  //array_push($ttarr,$rs_B['bidprice']*$rs_B['qty']);
			 
				  if($z==0)
				  {
					
						   /* $qry="SELECT f_id FROM finaltest WHERE pid='".$rs_B['product_id']."' AND vid='".$rs_B['vendid']."' AND bidid='".$rs_B['bid_id']."' ";   
							$sResult=$connector->query($qry); 
							if($connector->fnGetNumRows($sResult)==0){
								if($rs_M=$connector->fetchArray($sResult)) $f_id=$rs_M['f_id'];  
									$sZql ="INSERT INTO finaltest (pid,vid,bamt,bidid) VALUES ('".$rs_B['product_id']."','".$rs_B['vendid']."','".($rs_B['bidprice']*$rs_B['qty'])."','".$rs_B['bid_id']."')"; 
									$qExec=$connector->query($sZql);
						}  */
				   } 
//Here i am created two combination of that arrays
			
				$pp++; echo $pp."row".$numrow;
				if($pp==$numrow)
				{
					for($i=0;$i<$numrow-1;++$i)
					{ 
					   for($j=$i+1;$j<$numrow;++$j)
					   {
										//  echo $indTot[$p][$i]." + ".$indTot[$p][$j].'<BR>';
									   $vendTwoComb[]=$indTot[$i]+$indTot[$j];
									   $vendTwoCombAmt[]=$indTot[$i]."+".$indTot[$j];  
									   $vendTwoCombVids[]=$indVid[$i]."+".$indVid[$j];  
									   $vendTwoCombPids[]=$indPid[$i]."+".$indPid[$j]; 
									   //echo $indPid[$p][$i]." + ".$indPid[$p][$j].'<BR>';
					   }
					}
					
				  print_r($vendTwoComb); echo count($vendTwoComb);
				echo "----".$jj=count($vendTwoComb);

// I want to delete or clear all values of array here 					
					for($x=0;$x<$jj;$jj--)			
					{
					unset($indTot[$x]); 
					unset($indVid[$x]); 
					unset($indPid[$x]); 
					$x++;
				    }
			    }
						

			 $l++;
		}
		$tamts[]=$total;
		
		echo '<TR bgcolor="#FFFFFF">  
			 <TD align=center height="35px" class="text13"><B>Total Bid Amount</B></TD><TD align=left colspan=3  height="35px" class="text13"> $ <B>'.sprintf("%1.2f",$total).'</B></TD>
		     </TR>';	
$z++;		
}

Please give me suggestion to how to do this??
Attached Files
File Type: txt db.txt (125.6 KB, 21 views)
Last edited by Aamit; May 31st, 2009 at 6:13 pm.
Similar Threads
Reputation Points: 3
Solved Threads: 15
Posting Whiz
Aamit is offline Offline
341 posts
since Apr 2008
May 31st, 2009
0

Re: delete or clear array??

PHP Syntax (Toggle Plain Text)
  1. $array = array();

That will clear an array.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Jun 1st, 2009
0

Re: delete or clear array??

You can also use

PHP Syntax (Toggle Plain Text)
  1. unset($array);
Moderator
Reputation Points: 457
Solved Threads: 101
Nearly a Posting Virtuoso
digital-ether is offline Offline
1,250 posts
since Sep 2005

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: How to insert checkbox data into mysql?
Next Thread in PHP Forum Timeline: display data from a excel file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC