moldboy 0 Report post Posted June 14, 2005 I have written a piece of code that is to make a forum which contains a table consiting of two colums and a determind number of rows with a while loop, however when I test the page it goes and goes, and then returns an error stating that the maximum 30 second limit has been reached, I understand what that means I just don't know why it's looping forever: while ($weightnum > 0); { echo "<tr>"; echo '<td><input name="wname"' . $appendval . ' type="text" id="wname" value="Catagorie Name"></td>'; echo '<td><input name="wper"' . $appendval . ' type="text" id="wper" value="Percent Value"></td>'; echo "</tr>"; $appendval = $apendval + 1; $weightnum = $weightnum - 1; } Also Am I appending a number to my variable correctly? Share this post Link to post Share on other sites
Tyssen 0 Report post Posted June 14, 2005 Have you specified an initial value for $weightnum anywhere? Cos if you haven't, your counter doesn't know what it's s'posed to be counting down from. I would've thought it'd be easier to count up, but I don't s'pose it really matters. Share this post Link to post Share on other sites
moldboy 0 Report post Posted June 14, 2005 (edited) Yeah it pulls it from a forum page, I guess I could check to make sure I spelled it right. I also have a habbit of using the $ in my form variables, could check.Also on the last two lines, could I not say: $appendval = ++;$weightnum = --;?? Notice from BuffaloHELP: Edited as per request. Edited June 14, 2005 by BuffaloHELP (see edit history) Share this post Link to post Share on other sites
vujsa 0 Report post Posted June 14, 2005 Also on the last two lines, could I not say: $appendval = ++;$weightnum = --; 150865[/snapback] Should be done like this: $appendval++;$weightnum--; That will increment or decrement the variable. Also, I wrote a tutorial about this type of PHP scripting. It's on Xisto, the sister site to Xisto. Here is the tutorial link: Rapid HTML code generation using simple PHP It might interest you. vujsa Share this post Link to post Share on other sites
moldboy 0 Report post Posted June 15, 2005 Okay, I kinda have to vent here for just one moment, STUPID PHP AND IT'S STUPID LITTLE ISSUES.So I found out what the problem was. Turns out that while ($weightnum > 0);{echo "<tr>"; echo '<td><input name="wname"' . $appendval . ' type="text" id="wname" value="Catagorie Name"></td>'; echo '<td><input name="wper"' . $appendval . ' type="text" id="wper" value="Percent Value"></td>'; echo "</tr>";$appendval = $apendval + 1;$weightnum = $weightnum - 1;} won't work however:while ( $weightnum > 0 ){echo "<tr>"; echo '<td><input name="wname"' . $appendval . ' type="text" id="wname" value="Catagorie Name"></td>'; echo '<td><input name="wper"' . $appendval . ' type="text" id="wper" value="Percent Value"></td>'; echo "</tr>";$appendval = $apendval + 1;$weightnum = $weightnum - 1;} That does... can you spot the diffrence? Look at the {.Oh but thanks for the tutorial link, I just might have to use it. One rep point. Share this post Link to post Share on other sites
Tyssen 0 Report post Posted June 15, 2005 Yeah, I've had the same problem. I've only recently been playing around with PHP - before that it was all ASP - and I'm always getting caught out by missing ; and { which are a lot harder to spot than a missing then or end if. Share this post Link to post Share on other sites
moldboy 0 Report post Posted June 15, 2005 Yeah the only other coding I've even kinda done is HTML, and I'll tell you, PHP may be easy but HTML certinaly is easier! It's just not so picky. Share this post Link to post Share on other sites
karlo 0 Report post Posted June 17, 2005 I have written a piece of code that is to make a forum which contains a table consiting of two colums and a determind number of rows with a while loop, however when I test the page it goes and goes, and then returns an error stating that the maximum 30 second limit has been reached, I understand what that means I just don't know why it's looping forever: while ($weightnum > 0); { echo "<tr>"; echo '<td><input name="wname"' . $appendval . ' type="text" id="wname" value="Catagorie Name"></td>'; echo '<td><input name="wper"' . $appendval . ' type="text" id="wper" value="Percent Value"></td>'; echo "</tr>"; $appendval = $apendval + 1; $weightnum = $weightnum - 1; } Also Am I appending a number to my variable correctly? 150853[/snapback] I suggest using for() loops instead of while. In for(), it's easy... example is below: for($i=0;$i<5;$i++){echo("testing $i<br>");} Share this post Link to post Share on other sites
beeseven 0 Report post Posted June 18, 2005 The reason HTML is easier is because it's not a real language. HTML is markup: that means it tells stuff what to look like. It's not considered a language because there are no variables or conditionals or stuff like that. Share this post Link to post Share on other sites
moldboy 0 Report post Posted June 18, 2005 The reason HTML is easier is because it's not a real language. HTML is markup: that means it tells stuff what to look like. It's not considered a language because there are no variables or conditionals or stuff like that. 152601[/snapback] Yeah I know, that's why I wanted to learn an actual rograming language. Hence PHP Share this post Link to post Share on other sites