3 Replies - 1086 Views - Last Post: 17 December 2008 - 04:29 PM Rate Topic: -----

#1 foxkj  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 14-August 08

Putting multiple items from dtbs into one variable

Post icon  Posted 17 December 2008 - 01:56 PM

I have a php that gets multiple items from the database:


while (!$XtremeD->EOF()) {   
	 echo $XtremeD->DisplayInfo("Name"); 
	 echo $XtremeD->DisplayInfo("Quantity"); 
	 $XtremeD->MoveNext();
	 }
$XtremeD->MoveFirst();




I took tons out of there, but that part works....I just wanted to show that I'm using a "while" loop to get things out of the database.

My problem is, I want to take the results of the "while" loop and put it into one variable.

I cannot figure out how to do that.

I tried putting the loop in a fuction and calling it within a variable like this:

function cookie_order(){
	   while (!$XtremeD->EOF()){
	   echo $XtremeD->DisplayInfo("Name");
	   echo $XtremeD->DisplayInfo("Quantity");
	  $XtremeD->MoveNext();
	   }
}

$cookies = cookie_order();



(and that is the exact code I'm using), but it didn't work - it returned a "Call to a member function on a non-object".

I'm basically at a loss. Any ideas?

Is This A Good Question/Topic? 0
  • +

Replies To: Putting multiple items from dtbs into one variable

#2 foxkj  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 14-August 08

Re: Putting multiple items from dtbs into one variable

Posted 17 December 2008 - 02:57 PM

Hey So I got it to work....part way!!!!!

Here is my code. I need to put this within a variable so I can send it in a mail function:

if (!$XtremeD->EOF() >= 2){
	 while (!$XtremeD->EOF()){
	 echo $XtremeD->DisplayInfo("Name");
	 $XtremeD->MoveNext();
	 } 
}





Anybody know how to do that? Put a "if" statement within a variable? Perhaps first include it in a function???
Was This Post Helpful? 0
  • +
  • -

#3 foxkj  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 14-August 08

Re: Putting multiple items from dtbs into one variable

Posted 17 December 2008 - 03:33 PM

well, thanks for all the help :blink:

Here's the code. I guess posting it helped me think it out at least:


if (!$XtremeD->EOF() >= 2){
	while (!$XtremeD->EOF()){
		$cookieOne = $XtremeD->DisplayInfo("Name");
		$quantityOne = $XtremeD->DisplayInfo("Quantity");
		
		$XtremeD->MoveNext();
		$cookieTwo = $XtremeD->DisplayInfo("Name");
		$quantityTwo = $XtremeD->DisplayInfo("Quantity");
		
		$XtremeD->MoveNext();
		$cookieThree = $XtremeD->DisplayInfo("Name");
		$quantityThree = $XtremeD->DisplayInfo("Quantity");
		
		$XtremeD->MoveNext();
		$cookieFour = $XtremeD->DisplayInfo("Name");
		$quantityFour = $XtremeD->DisplayInfo("Quantity");
		
		$XtremeD->MoveNext();
		$cookieFive = $XtremeD->DisplayInfo("Name");
		$quantityFive = $XtremeD->DisplayInfo("Quantity");
		
		$XtremeD->MoveNext();
		$cookieSix = $XtremeD->DisplayInfo("Name");
		$quantitySix = $XtremeD->DisplayInfo("Quantity");
		
		$XtremeD->MoveNext();
		$cookieSeven = $XtremeD->DisplayInfo("Name");
		$quantitySeven = $XtremeD->DisplayInfo("Quantity");
		
		$XtremeD->MoveNext();
		$cookieEight = $XtremeD->DisplayInfo("Name");
		$quantityEight = $XtremeD->DisplayInfo("Quantity");
		$XtremeD->MoveNext();
	} 
}




Of course, this is probably the long-hand way of writing it, but I didn't know how to add numbers to the variables automatically, and since I only have eight items, I figured this would work till I learn how to do it better.

If anyone know a short-hand way, please post!
Was This Post Helpful? 0
  • +
  • -

#4 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 542
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: Putting multiple items from dtbs into one variable

Posted 17 December 2008 - 04:29 PM

If $XtremeD is a variable referencing a class you wrote, then putting that on here without posting the class basically doesn't show us anything you're doing at all. Sure, we could get an idea of it by reading the function names from the class you're referencing, but without posting the class, no one's gonna have a clue.

Just a note for the future, if the code gives you any further difficulties.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1