Jump to content


Photo

Can anyone see what i am doing wrong here?


  • Please log in to reply
3 replies to this topic

#1 smith.james0

smith.james0
  • Members
  • PipPipPip
  • Advanced Member
  • 122 posts

Posted 01 March 2006 - 09:56 PM

$vCht4 = array(
for ($i = 1; $i <= 52; $i++) {

if ($i < 10) {
$i = "0" . $i;
}$salescum[$i],
});

Can this be done at all?

Thanks

#2 dmcalerney

dmcalerney
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 01 March 2006 - 10:07 PM

That didn't work for me. If I understand what you are trying to do, this might work a little bit better.

<?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>";
}


?>


#3 smith.james0

smith.james0
  • Members
  • PipPipPip
  • Advanced Member
  • 122 posts

Posted 01 March 2006 - 10:16 PM

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 array

array($salescum['01'],$salescum['02']...etc...,$salescum['52']);

I need it to insert the results into the array 52 time.

James

#4 php_b34st

php_b34st
  • Members
  • PipPipPip
  • Advanced Member
  • 168 posts

Posted 01 March 2006 - 10:25 PM

Try putting the following before your for loop:

$salescum = array();





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users