You are here: Re: help with a bucle « PHP « IT news, forums, messages
Re: help with a bucle

Posted by "sonu gill" on 08/03/05 06:26

Sorry clarification required to my previous answer...

I sort of answered you in a hurry, and I made another assumption that I
didn't define.

I wanted to clarify that I'm assuming the array is setup as follows
arr[day]=>report.

arr[1]=>45
arr[2]=>56
arr[4]=>78
etc...


$y = 31;

for($x=0; $x < $y; $x++)
{
echo "day ". ($x+1) ." ----- report " . ((isset($arr[$x+1]))?
$arr[$x+1]:"0") . "<br />"; //$x+1 is required because you can never have
day 0
}

""sonu gill"" <sonugill@sonugill.com> wrote in message
news:AE.A3.04646.34330F24@pb1.pair.com...
> From what I gathered you simply want to print all days and the "reporte"
> field info and if there isn't any then 0.
>
> Assuming you used SQL and retrieved your information from the db into an
> associated Array
>
> $arr //the results from the DB...
>
> $y = 31; //Assuming you are working with 31 days...
>
> for($x=0; $x<$y; $x++)
> {
> echo "day ". ($x+1) ." ----- report " . ((isset($arr[$x+1]))?
> $arr[$x+1]:"0") . "<br />"; //$x+1 is required because you can never have
> day 0
> }
>
> hope this helps...
>
> -sonu
>
>
> ""Jesϊs Alain Rodrνguez Santos"" <wmaster@cfg.jovenclub.cu> wrote in
> message
> news:1974.192.168.6.61.1123038296.squirrel@correo.cfg.jovenclub.cu...
>> Hi, i have in my mysql db one table columm, some think like this:
>>
>> day reporte
>> --- -------
>> 1 45
>> 2 56
>> 4 78
>> 6 89
>> 7 90
>> etc...
>>
>> How can i print all the value from 'reporte' columm depending the 'day'
>> columm, and if there is not exist a day print 0 value, for example:
>>
>> day 1 ----- reporte 45
>> day 2 ----- reporte 56
>> day 3 ----- 0
>> day 4 ----- reporte 78
>> day 5 ----- 0
>> etc...
>>
>> Sorry for my english
>>
>>
>> --
>> Este mensaje ha sido analizado por MailScanner
>> en busca de virus y otros contenidos peligrosos,
>> y se considera que estα limpio.

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация