kitchen Posted January 18, 2007 Share Posted January 18, 2007 [code] function listQueue($category) { global $total; global $arr_id; global $arr_am; $query = "SELECT * FROM market WHERE cat = '$category'"; $result = mysql_query($query); while($item = mysql_fetch_array($result)) { $amount = $_POST[$item['id']]; if(is_numeric($amount)) { if($amount > 0) { $itotal = $item['cost'] * $amount; $total = $total + $itotal; $fitotal = number_format($item['cost'] * $amount); $fcost = number_format($item['cost']); $famount = number_format($amount); $arr_id[$i] = "$item[id]"; $arr_am[$i] = "$amount"; $i++; } } } }#Lots of code was here, I removed it all it did was teh call fucntion and thats not the problem :-P foreach($arr_am as $aa) { foreach($arr_id as $ai) { $x = 0; while($aa > $x) { echo $ai; $x++; } } } [/code]Ok so now my problem is this, I have lots of forms where the amounts are being entered. Lets use 2 of them as an example. I enter the value of 1 in to form 1I enter the value of 2 in to form 2I want the output to be: 122The current output is:121122Hope that makes sense if not, please ask for what more information you need. Quote Link to comment https://forums.phpfreaks.com/topic/34713-arrays-and-loops/ Share on other sites More sharing options...
chiprivers Posted January 18, 2007 Share Posted January 18, 2007 [quote]I enter the value of 1 in to form 1I enter the value of 2 in to form 2I want the output to be: 122The current output is:121122[/quote]What are you talking about???? Quote Link to comment https://forums.phpfreaks.com/topic/34713-arrays-and-loops/#findComment-163613 Share on other sites More sharing options...
boo_lolly Posted January 18, 2007 Share Posted January 18, 2007 i [i]think[/i] he means he wants the output 122 to mean that the first value was 1, the second value was 2, and there were 2 forms total where data was entered... that's as far as i got. Quote Link to comment https://forums.phpfreaks.com/topic/34713-arrays-and-loops/#findComment-163794 Share on other sites More sharing options...
kitchen Posted January 19, 2007 Author Share Posted January 19, 2007 [quote author=boo_lolly link=topic=122957.msg507920#msg507920 date=1169140355]i [i]think[/i] he means he wants the output 122 to mean that the first value was 1, the second value was 2, and there were 2 forms total where data was entered... that's as far as i got.[/quote]thats percisely what i want to do! Quote Link to comment https://forums.phpfreaks.com/topic/34713-arrays-and-loops/#findComment-164115 Share on other sites More sharing options...
chiprivers Posted January 19, 2007 Share Posted January 19, 2007 so you have various forms, the user enteres a number into a choice of the forms, you are then returned with a string of numbers where the first numbers are the values entered in the forms and the last number if the number of entries?? Quote Link to comment https://forums.phpfreaks.com/topic/34713-arrays-and-loops/#findComment-164628 Share on other sites More sharing options...
kitchen Posted January 19, 2007 Author Share Posted January 19, 2007 Almost like that. I have various forms, each labeled by id's taken from a mysql database, i want the output to equal the id number, repeated X amount of times (x = what number u entered in the form)so lemme say the example a little clearer :Puser enters the value 1 into the form labled 4, the user enters the value 2 label 5 - the output is 454455, but I want the output to be 455Hope you can make sense out of that lol Quote Link to comment https://forums.phpfreaks.com/topic/34713-arrays-and-loops/#findComment-164714 Share on other sites More sharing options...
kitchen Posted January 19, 2007 Author Share Posted January 19, 2007 If someone would like to contact me and see the page I'm talking about and then help me from there my AIM is lxhaxorxl Quote Link to comment https://forums.phpfreaks.com/topic/34713-arrays-and-loops/#findComment-164728 Share on other sites More sharing options...
sasa Posted January 20, 2007 Share Posted January 20, 2007 try[code]foreach($arr_am as $ai => $aa) { // foreach($arr_id as $ai)// { $x = 0; while($aa > $x) { echo $arr_id[$ai]; $x++; }// } } [/code] Quote Link to comment https://forums.phpfreaks.com/topic/34713-arrays-and-loops/#findComment-164878 Share on other sites More sharing options...
kitchen Posted January 20, 2007 Author Share Posted January 20, 2007 [quote author=sasa link=topic=122957.msg509030#msg509030 date=1169267307]try[code]foreach($arr_am as $ai => $aa) { // foreach($arr_id as $ai)// { $x = 0; while($aa > $x) { echo $arr_id[$ai]; $x++; }// } } [/code][/quote]Thanks dude! That works perfectly! EDIT: I can't find the topic solved link =/ Quote Link to comment https://forums.phpfreaks.com/topic/34713-arrays-and-loops/#findComment-164937 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.