Re: [PHP] for loop inside a switch

2007-08-31 Thread Robert Cummings
On Fri, 2007-08-31 at 15:56 -0700, Dan wrote: > Sanjeev is right. You're thinking about the problem backwards. You're > trying to build a Switch inside a loop. Remember, if you ever have to do > some operating multiple times you're using a forloop, then the thing that > you want to repeat(swi

Re: [PHP] for loop inside a switch

2007-08-31 Thread Dan
Sanjeev is right. You're thinking about the problem backwards. You're trying to build a Switch inside a loop. Remember, if you ever have to do some operating multiple times you're using a forloop, then the thing that you want to repeat(switch case) is INSIDE the for loop. - Dan ""Sanjeev N

RE: [PHP] for loop inside a switch

2007-08-17 Thread Sanjeev N
This will not work at all.. Instead of switch try with if condition as follows for ($i=0; $i <21; $i++) { if(faq$i == $q){ echo $faq1; break; } } Now it works.. You can write the code to display the result how you want.. but you cant write the code to write

Re: [PHP] for loop inside a switch

2007-08-16 Thread Jim Lucas
Hulf wrote: Hi, switch ($q) { for ($i=0; $i <21; $i++) { case 'faq$i': echo $faq1; break; } } I just want to loop out a big long list of cases. are the case's that you want to create with the loop going to be the only case statements in the switch? -- Jim Lucas "Some men are

Re: [PHP] for loop inside a switch

2007-08-16 Thread Dimiter Ivanov
On 8/16/07, Hulf <[EMAIL PROTECTED]> wrote: > Hi, > > switch ($q) { > > for ($i=0; $i <21; $i++) { > case 'faq$i': > echo $faq1; > break; > } > } > > > I just want to loop out a big long list of cases. Maybe you want this kind of functionality : http://www.php.net/manual/en/language.varia

Re: [PHP] for loop inside a switch

2007-08-16 Thread Stut
Hulf wrote: Hi, switch ($q) { for ($i=0; $i <21; $i++) { case 'faq$i': echo $faq1; break; } } I just want to loop out a big long list of cases. That's not a valid construct, but if I understand what you're trying do, this should work... $faqs = array(); for ($i = 0; $i < 21; $i+

Re: [PHP] for loop inside a switch

2007-08-16 Thread Mohamed Yusuf
I don't think it is going to work. IMO On 8/16/07, Hulf <[EMAIL PROTECTED]> wrote: > > Hi, > > switch ($q) { > > for ($i=0; $i <21; $i++) { > case 'faq$i': > echo $faq1; > break; > } > } > > > I just want to loop out a big long list of cases. > > -- > PHP General Mailing List (http://www.p

Re: [PHP] For Loop

2006-06-20 Thread D. Dante Lorenso
Albert Padley wrote: Thanks everyone. Always nice to know there is more than one direction to go in. A alternative to variable variables might use these: http://us3.php.net/manual/en/function.compact.php http://us3.php.net/manual/en/function.extract.php 'extract' looks like it might be

Re: [PHP] For Loop

2006-06-20 Thread Robert Cummings
On Tue, 2006-06-20 at 19:19, Albert Padley wrote: > Thanks everyone. Always nice to know there is more than one direction > to go in. > > Albert > > > On Jun 20, 2006, at 4:52 PM, Ray Hauge wrote: > > > On Tuesday 20 June 2006 15:28, Adam Zey wrote: > >> Ray Hauge wrote: > >>> On Tuesday 20 J

Re: [PHP] For Loop

2006-06-20 Thread Albert Padley
Thanks everyone. Always nice to know there is more than one direction to go in. Albert On Jun 20, 2006, at 4:52 PM, Ray Hauge wrote: On Tuesday 20 June 2006 15:28, Adam Zey wrote: Ray Hauge wrote: On Tuesday 20 June 2006 15:14, Albert Padley wrote: I have a regular for loop - for($i=1; $

Re: [PHP] For Loop

2006-06-20 Thread Ray Hauge
On Tuesday 20 June 2006 15:28, Adam Zey wrote: > Ray Hauge wrote: > > On Tuesday 20 June 2006 15:14, Albert Padley wrote: > >> I have a regular for loop - for($i=1; $i<100; $i++) > >> > >> Within the loop I need to create variables named: > >> > >> $p1name; > >> $p2name; > >> $p3name; > >> etc. > >

Re: [PHP] For Loop

2006-06-20 Thread David Tulloh
Are you sure that you don't want an array? Arrays are normally much better for this type of thing. That said, ${"p{$i}name"} = 'foo'; David Albert Padley wrote: > I have a regular for loop - for($i=1; $i<100; $i++) > > Within the loop I need to create variables named: > > $p1name; > $p2name;

Re: [PHP] For Loop

2006-06-20 Thread Adam Zey
Ray Hauge wrote: On Tuesday 20 June 2006 15:14, Albert Padley wrote: I have a regular for loop - for($i=1; $i<100; $i++) Within the loop I need to create variables named: $p1name; $p2name; $p3name; etc. The integer portion of each variable name needs to be the value of $i. I can't seem to ge

Re: [PHP] For Loop

2006-06-20 Thread Jeffrey Sambells
for($i=1; $i<100; $i++) { ${'p'.$i.'name'} = 'whatever'; } - jeff On 20-Jun-06, at 6:14 PM, Albert Padley wrote: I have a regular for loop - for($i=1; $i<100; $i++) Within the loop I need to create variables named: $p1name; $p2name; $p3name; etc. The integer portion of each variable

Re: [PHP] For Loop

2006-06-20 Thread Ray Hauge
On Tuesday 20 June 2006 15:14, Albert Padley wrote: > I have a regular for loop - for($i=1; $i<100; $i++) > > Within the loop I need to create variables named: > > $p1name; > $p2name; > $p3name; > etc. > > The integer portion of each variable name needs to be the value of $i. > > I can't seem to ge

Re: [PHP] For Loop

2004-12-08 Thread Travis Conway
try for($i=0;$i>$months_arr_length;$i++) look at it as this: for(i as starting point; till i is what? greater than my length; increment i how? by 1) { HTH Trav - Original Message - From: "R. Van Tassel" <[EMAIL PROTECTED]> To: "'PHP general'" <[EMAIL PROTECTED]> Sent: Wednesday, December

Re: [PHP] For Loop

2004-12-08 Thread hitek
$i = $months_arr_length is an assignment, not a comparison, so it will always evaluate to true, and you are setting your counter var to 12 every time the loop runs, that's why it runs infinitely. > > From: "R. Van Tassel" <[EMAIL PROTECTED]> > Date: 2004/12/08 Wed PM 04:41:00 EST > To: "'PHP g

Re: [PHP] For Loop

2004-12-08 Thread Gareth Williams
What happens is (if I understand it correctly): First, PHP sets $i to equal 0, and then immediately sets $i to $months_arr_length. Every time the loop executes, it resets $1 to $months_arr_length, so you are stuck in an infinite loop. The reason behind this is you are using assignment equals (=

Re: [PHP] For Loop Problems

2004-07-28 Thread Jason Barnett
[EMAIL PROTECTED] wrote: Hello Everyone, I'm building a hotel management system and I can't seem to figure out why my for() loop doesn't work the way it should. I'm using patTemplate to create the HTML Template (I like using it and I don't want to start a pro/con template war). Here is the script:

Re: [PHP] For Loop Problems

2004-07-28 Thread rush
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > for ($j = 0; $j < 32; $j++) { > for ($i = 0; $i < count($num_days); $i++) { > $template->addVar("room_num", "ROOM_NUM", '101'); > $template->addVar("room_type", "ROOM_TYPE", 'NQQ'); > $template->addVar("gues

Re: [PHP] for loop break and continue

2003-09-27 Thread Becoming Digital
AIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, 25 September, 2003 12:26 Subject: Re: [PHP] for loop break and continue Can't you let me have a shred of programming self-respect? Rich (I should have cracked the book) Fox > On Thu, 2003-09-25 at 12:04, Rich Fox wrote: > >

RE: [PHP] for loop break and continue

2003-09-25 Thread Jay Blanchard
[snip] Can't you let me have a shred of programming self-respect? Rich (I should have cracked the book) Fox [/snip] Nah, too easy! :) We all get bumped from time to time -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] for loop break and continue

2003-09-25 Thread Rich Fox
Can't you let me have a shred of programming self-respect? Rich (I should have cracked the book) Fox > On Thu, 2003-09-25 at 12:04, Rich Fox wrote: > > DOH! > > > > This is a new addition to PHP because it wasn't there before! > > > > Thanks for the slap. > > PHP has supported break for as long a

Re: [PHP] for loop break and continue

2003-09-25 Thread Robert Cummings
On Thu, 2003-09-25 at 12:04, Rich Fox wrote: > DOH! > > This is a new addition to PHP because it wasn't there before! > > Thanks for the slap. PHP has supported break for as long as I can remember which goes back to about 1999 and PHP 3.something. Cheers, Rob. -- .

Re: [PHP] for loop break and continue

2003-09-25 Thread Rich Fox
DOH! This is a new addition to PHP because it wasn't there before! Thanks for the slap. "Robert Cummings" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Take the sample code below, paste it to a PHP file, add a real > conditional, execute script. Voila, you've taken the first ste

Re: [PHP] for loop break and continue

2003-09-25 Thread Robert Cummings
Take the sample code below, paste it to a PHP file, add a real conditional, execute script. Voila, you've taken the first step towards helping yourself. Cheers, Rob. On Thu, 2003-09-25 at 11:42, Rich Fox wrote: > Hi, > Is there an equivalent to the C++ 'break' command to stop execution of a for

RE: [PHP] for loop and FTP

2003-08-14 Thread Jay Blanchard
[snip] I need to grab five pages from a web site every day and then FTP those pages to another site. I was wondering if I should grab all five pages (and store them somewhere) and then FTP all five. [/snip] This sounds like the more prudent move as it is more efficient. You can also confirm that

Re: [PHP] for loop and array

2002-09-24 Thread Justin French
I think you add square brackets: so you'd have an array with a numeric key (0-n) and the value of the key would be the value of the input. or perhaps you'd prefer in this case the key of the array would be 'Hepb_ag', and the value would be true (1). In both cases, I don't think anything is

RE: [PHP] For Loop going too long

2002-03-30 Thread Demitrious S. Kelly
Try a foreach... it works well... -Original Message- From: Lars Torben Wilson [mailto:[EMAIL PROTECTED]] On Behalf Of Lars Torben Wilson Sent: Saturday, March 30, 2002 4:38 PM To: David Johansen Cc: [EMAIL PROTECTED] Subject: Re: [PHP] For Loop going too long On Sat, 2002-03-30 at 15:40

Re: [PHP] For Loop going too long

2002-03-30 Thread Lars Torben Wilson
On Sat, 2002-03-30 at 15:40, David Johansen wrote: > I have a question about something weird that I've noticed Here's some code > that I have that loads up > >$sql = "SELECT * FROM pickup_times WHERE DAYOFMONTH(time0_name) = > $dayofmonth"; > >$result = mysql_query($sql, $dbh); >$day

Re: [PHP] for loop problem

2002-03-20 Thread Miguel Cruz
On Wed, 20 Mar 2002, Kris Vose wrote: > I have a problem with a piece of code that uses the mail function in a > for loop. It sends out mail to all the users in the database but it has > a problem with attaching their specific name into the message. What > happens is the first user in the databa

Re: [PHP] for loop problem

2002-03-20 Thread cal
Opps, last messages had the definition of $originalMessage in the wrong place. Try this: If ($button != "") { $t = mysql_query("SELECT * from AddExisting"); $number_of_customers = mysql_num_rows($t); $originalMessage = $message; for($i

Re: [PHP] for loop problem

2002-03-20 Thread cal
Try this: If ($button != "") { $t = mysql_query("SELECT * from AddExisting"); $number_of_customers = mysql_num_rows($t); for($i=0; $i<$number_of_customers;$i++) { $r = mysql_fetch_array($t);

Re: [PHP] for loop problem?

2001-11-13 Thread jimmy elab
Tyler Longren wrote: > > Here's something interesting though. There's an id field that's set to > AUTO_INCREMENT. Yep, and that's one thing I've been looking at. See, I find it strange that you need an KEY idpass (id, passcode(245)) when the ID is quaranteed to be unique in itself. Funny...

Re: [PHP] for loop problem?

2001-11-13 Thread John Steele
>work. > >Tyler > >----- Original Message - >From: "John Steele" <[EMAIL PROTECTED]> >To: "PHP General List" <[EMAIL PROTECTED]> >Sent: Monday, November 12, 2001 3:33 PM >Subject: Re: [PHP] for loop problem? > > >&g

Re: [PHP] for loop problem?

2001-11-12 Thread Christopher William Wesley
> work. > > Tyler > > - Original Message - > From: "John Steele" <[EMAIL PROTECTED]> > To: "PHP General List" <[EMAIL PROTECTED]> > Sent: Monday, November 12, 2001 3:33 PM > Subject: Re: [PHP] for loop problem? > > > > Hi Ty

Re: [PHP] for loop problem?

2001-11-12 Thread Tyler Longren
this PHP SHOULD work. Tyler - Original Message - From: "John Steele" <[EMAIL PROTECTED]> To: "PHP General List" <[EMAIL PROTECTED]> Sent: Monday, November 12, 2001 3:33 PM Subject: Re: [PHP] for loop problem? > Hi Tyler, > > This doesn't s

Re: [PHP] for loop problem?

2001-11-12 Thread John Steele
t; >Shouldn't the ID's be further apart than that? Know what I'm saying? > >Tyler > >- Original Message - >From: "Martin Towell" <[EMAIL PROTECTED]> >To: "'Tyler Longren'" <[EMAIL PROTECTED]>; "Jack Dempsey" >&

Re: [PHP] for loop problem?

2001-11-12 Thread Tyler Longren
r Longren'" <[EMAIL PROTECTED]>; "Jack Dempsey" <[EMAIL PROTECTED]> Cc: "PHP-General" <[EMAIL PROTECTED]> Sent: Monday, November 12, 2001 10:45 PM Subject: RE: [PHP] for loop problem? > How about changing the logic lightly? try this: > >

RE: [PHP] for loop problem?

2001-11-12 Thread Martin Towell
bers then adding it back on later Martin T -Original Message- From: Tyler Longren [mailto:[EMAIL PROTECTED]] Sent: Tuesday, November 13, 2001 3:38 PM To: Jack Dempsey Cc: PHP-General Subject: Re: [PHP] for loop problem? I've ran it a few times without the MySQL code in there. Runs

Re: [PHP] for loop problem?

2001-11-12 Thread Tyler Longren
x27;passcodes' field. Oh well, here I come perl! Thanks, Tyler - Original Message - From: "Jack Dempsey" <[EMAIL PROTECTED]> To: "Tyler Longren" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Monday, November 12, 2001 10:43 PM Subject: RE: [

RE: [PHP] for loop problem?

2001-11-12 Thread Jack Dempsey
loop problem? Exact code: ".mysql_error().""; exit; } } mysql_close($connection); ?> Tyler - Original Message - From: "Jack Dempsey" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, November 12, 2001 10:34 PM Subject: RE: [PHP] for loop

Re: [PHP] for loop problem?

2001-11-12 Thread Tyler Longren
Exact code: ".mysql_error().""; exit; } } mysql_close($connection); ?> Tyler - Original Message - From: "Jack Dempsey" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, November 12, 2001 10:34 PM Subject: RE: [PHP] for loop problem?

RE: [PHP] for loop problem?

2001-11-12 Thread Jack Dempsey
paste the complete code in and myself and others can run your exact copy -Original Message- From: Tyler Longren [mailto:[EMAIL PROTECTED]] Sent: Monday, November 12, 2001 11:22 PM To: Martin Towell; [EMAIL PROTECTED] Subject: Re: [PHP] for loop problem? I removed all of the quotes that

Re: [PHP] for loop problem?

2001-11-12 Thread Tyler Longren
Sent: Monday, November 12, 2001 10:06 PM Subject: RE: [PHP] for loop problem? > hmmm... I just tried : > > $value1 = 100; > $value2 = 1223109; > for($i = $value1; $i <= $value2; $i++) > { > echo "$i\n"; > } > > and it spat out all 223109 numbers

RE: [PHP] for loop problem?

2001-11-12 Thread Martin Towell
e- From: Tyler Longren [mailto:[EMAIL PROTECTED]] Sent: Tuesday, November 13, 2001 2:53 PM To: Evan Nemerson; [EMAIL PROTECTED] Subject: Re: [PHP] for loop problem? To everyone that said it had something to do with the quotes: that has nothing to do with it. When I first wrote this, It didn

Re: [PHP] for loop problem?

2001-11-12 Thread Tyler Longren
I HAVE to, I'll do this in PERL, but would much rather do it in PHP. Thanks everyone, Tyler - Original Message - From: "Evan Nemerson" <[EMAIL PROTECTED]> To: "Tyler Longren" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Monday, November 12, 200

Re: [PHP] for loop problem?

2001-11-12 Thread Evan Nemerson
My word why all the quotes? ".mysql_error().""; exit; } } mysql_close($connection); ?> That should give you some better results. On Monday 12 November 2001 07:32 pm, you wrote: > Hello everyone, > > I have a pretty big list of codes that need to be put into a mysql db. The > numbers range

RE: [PHP] for loop problem?

2001-11-12 Thread Martin Towell
try removing the quotes and see if that works eg $value1 = "100"; becomes $value1 = 100; and for($i="$value1"; $i<="$value2"; $i++) { becomes for($i=$value1; $i<=$value2; $i++) { Martin T -Original Message- From: Tyler Longren [mailto:[EMAIL PROTECTED]] Sent: Tuesday, November 1

Re: [PHP] for loop changes?

2001-09-14 Thread Mark Charette
From: "Michael Gerholdt" <[EMAIL PROTECTED]> > I want the week and month days to have leading zeros - how can I make the > new environment replicate the old? Loop using the numeric but use printf for the formatting (which is really what you should have used originally). Refer to the manual for t