Preserved Topic: while (new to php) { $efforts='disaster'; } |
|
---|---|
Author | Thread |
Nervous Wreck (II) Inmate From: Everywhere and Nowhere |
posted 09-19-2002 15:27
($while) { |
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 09-19-2002 15:43
Well you are on the right track but when dealing with Arrays it is normally a better idea to use a for loop. code: <?
|
Maniac (V) Mad Scientist with Finglongers From: Cell 53, East Wing |
posted 09-19-2002 15:43
Mormegil: Welcome. Here is what I'd do: code: <?php
|
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 09-19-2002 15:44 |
Nervous Wreck (II) Inmate From: Everywhere and Nowhere |
posted 09-19-2002 16:07
Ok, what if I were querying a database, though, and wanted it to print for as many arrays as there are in the database? It doesn't seem like that is something that I can hardcode every time I change the amount of available prices that there are. Does that sentence make sense? |
Maniac (V) Mad Scientist with Finglongers From: Cell 53, East Wing |
posted 09-19-2002 16:22
WarMage: You're mean code: $db = mysql_connect("localhost", "USERNAME", "PASSWORD") or die ("Couldn't connect to server");
|
Nervous Wreck (II) Inmate From: Everywhere and Nowhere |
posted 09-19-2002 16:28
I think that may work, but I did try while($row < count($a)) and it worked just fine. Thanks for all of your help. But I have one last question: In looking through other peoples code, I have seen while ($somevariable) and I am interested to know when you would want to use a lone variable as an expression. I looked through phpbuilders definition of while and even phpnet, but could find no example of this. Hope I'm not pestering you. That will be the last question, I swear. |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 09-19-2002 17:39
2 things first a foreach loop's easier than a for loop in php |
Paranoid (IV) Mad Scientist From: Somewhere over the rainbow |
posted 09-19-2002 18:49
The poster has demanded we remove all his contributions, less he takes legal action. |
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 09-19-2002 19:59
When you have something that will return a boolean value you might use while($variable) code: $variable = true;
|
Nervous Wreck (II) Inmate From: Everywhere and Nowhere |
posted 09-19-2002 20:10
Thank you for your help, all. Very good stuff. I quite understand alot more now than when I started, and everything you said made sense to me. |
Paranoid (IV) Mad Scientist From: Somewhere over the rainbow |
posted 09-19-2002 20:50
The poster has demanded we remove all his contributions, less he takes legal action. |