smith.james0 Posted March 1, 2006 Share Posted March 1, 2006 $vCht4 = array(for ($i = 1; $i <= 52; $i++) { if ($i < 10) { $i = "0" . $i; }$salescum[$i], });Can this be done at all?Thanks Quote Link to comment https://forums.phpfreaks.com/topic/3864-can-anyone-see-what-i-am-doing-wrong-here/ Share on other sites More sharing options...
dmcalerney Posted March 1, 2006 Share Posted March 1, 2006 That didn't work for me. If I understand what you are trying to do, this might work a little bit better.[code]<?php$vCht4 = array();for ($i = 1; $i <= 52; $i++){ if ($i < 10) { $temp = "0" . $i; } else { $temp = $i; } $salescum[$i] = $temp;}$vCht4 = $salescum;for ($i = 1; $i < sizeof($salescum); $i++){ ECHO $salescum[$i] . "<br>";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/3864-can-anyone-see-what-i-am-doing-wrong-here/#findComment-13415 Share on other sites More sharing options...
smith.james0 Posted March 1, 2006 Author Share Posted March 1, 2006 Thanks for the quick reply, that not quite what i am looking for. I have queryed the db for ($i = 1; $i <= 52; $i++) { if ($i < 10) { $i = "0" . $i; }$sqlsum = "SELECT SUM(sales) AS sum FROM ******* WHERE week='$i' AND year='2006'";$resultsales = mysql_query($sqlsum,$db) or die ("Invalid query");$rowsales = mysql_fetch_assoc($resultsales);$salescum[$i] = $rowsales['sum'];}And i now need to put all 52 results into a arrayarray($salescum['01'],$salescum['02']...etc...,$salescum['52']);I need it to insert the results into the array 52 time.James Quote Link to comment https://forums.phpfreaks.com/topic/3864-can-anyone-see-what-i-am-doing-wrong-here/#findComment-13420 Share on other sites More sharing options...
php_b34st Posted March 1, 2006 Share Posted March 1, 2006 Try putting the following before your for loop:[code]$salescum = array();[/code] Quote Link to comment https://forums.phpfreaks.com/topic/3864-can-anyone-see-what-i-am-doing-wrong-here/#findComment-13422 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.