php While logic

This is a discussion on "php While logic" within the PHP Forum section. This forum, and the thread "php While logic are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jan 31st, 2007, 20:54
New Member
Join Date: Oct 2006
Location: Asheville NC
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
php While logic

can you help me fix this php code?


<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtmll/DTD/xhtmll-strict.dtd">
<html>
<head>
<title>While Logic</title>

</head>
<body>
<?php
/*
Demond Carson
January 23, 2007
*/
$Count = 0;
while ($Count <= 100) {
$Numbers[] = $Count;
++$Count;
foreach ($Count as $curNum)
echo "<p>$CurNum</p>";
}
?>
</body>
</html>
Reply With Quote

  #2 (permalink)  
Old Jan 31st, 2007, 21:37
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php While logic

$Count++; instead of ++$Count?
Reply With Quote
  #3 (permalink)  
Old Feb 1st, 2007, 11:32
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: php While logic

Quote:
Originally Posted by dcarson View Post
can you help me fix this php code?
foreach ($Count as $curNum)
echo "<p>$CurNum</p>";
$CurNum is not initialized.
This is the danger with using cute inner caps, or any caps, with php variables. I suggest you use all lowercase for all variables. If you want to use javascript style for functions, that's another matter.

#2 What is this trying to do? You have a foreach loop inside a while loop (or following a while loops, it's impossible to parse) with incorrect syntax. Furthermore, $Count is not an array.

You need to study up on some very basic php principles before you start coding.

Last edited by JacobHaug; Feb 7th, 2007 at 18:46.
Reply With Quote
  #4 (permalink)  
Old Feb 7th, 2007, 18:46
JacobHaug's Avatar
SuperMember

SuperMember
Join Date: Dec 2005
Location: On Internet
Posts: 4,859
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to JacobHaug Send a message via MSN to JacobHaug
Re: php While logic

I think that is why he came to this website...to get assistance with his code, and help from you.

Last edited by JacobHaug; Feb 12th, 2007 at 16:23.
Reply With Quote
Reply

Tags
code not working, php help

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Logic Problem involving loops and arrays tox0tes Other Programming Languages 5 Oct 28th, 2007 03:11
Anybody use flow charts for logic design? Donny Bahama PHP Forum 3 May 8th, 2007 15:44
Logic help jayaime JavaScript Forum 4 Aug 31st, 2006 14:28
Benbacardi's code logic netwarriorgizmo JavaScript Forum 2 Jul 29th, 2004 09:53


All times are GMT. The time now is 01:57.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43