Page 1 of 1

Trouble putting data into database...??

Posted: Sun Mar 19, 2006 1:29 pm
by civic3x98
feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi,

I have this piece of code which i am getting the below data

Code: Select all

session_start();
$ArrayList = array("_GET", "_POST", "_SESSION", "_COOKIE", "_SERVER");
foreach($ArrayList as $gblArray)
{
   $keys = array_keys($$gblArray);
   foreach($keys as $key)
   {
       $$key = trim(${$gblArray}[$key]);
	   
   }
}

Code: Select all

for ($x = 0; $x < $items; $x++)
{
	$qty = "qty";
	$units = "units";
	$color = "color";
	
	${$qty.$x};
	${$units .$x};
	${$color .$x};
}
The above code will put out X amount of "qty" & "Units" & "Color" depending on how many items there are.

So it might come out like:

Code: Select all

3   pens   blue
5   gloves   brown
and so on
I need to put all of that into a single string. Something like:

Code: Select all

$string = ${$qty.$x} . " " . ${$units .$x} . " " . ${$color .$x} . "<br>";
The problem is, the code is in the FOR loop like you see above. If i put the $string into the FOR loop, $string will loose the value of the prev loop, and get new info from the current loop.

How can I get all loops into one string?

Thanks![/i]


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sun Mar 19, 2006 8:25 pm
by feyd
time to read up on how string operators work.

hint: it involves a dot.