Battle Zone
We think you should log in. Don't you?


This is the site for everything and anything you want to talk about. Want to discuss the latest games? Done. Want to have fun? Done. This is THE place to have a great time.
 
HomePortalFAQMemberlistRegisterLog in

Share | 
 

 Issues with breaks

View previous topic View next topic Go down 
AuthorMessage
Naptime
Book Moderator
avatar

Join date : 2010-03-10
Rank : Book Section Moderator

Posts : 141


PostSubject: Issues with breaks   Tue Mar 16, 2010 9:26 am

Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
      <title>
         Packet Example 37
      </title>
   </head>
   <body>
      <table border="1">
         <tr>
   <!-- Author: James Huffman -->
   <?php
      $k=0;
      $c=0;
      
      while ($k <= 10)
         {
               $x=rand(0,9);
               $y=rand(0,9);
               $z=$x%$y;
               
            if ($c == 1 && $z == 0)
               {
                  echo "</tr><tr><td>".$x."</td><td align='center'> / </td><td>".$y."</td><td> Error! </td>";
                  $c=0;
               }
            elseif (c == 1)
               {
                  echo "</tr><tr><td>".$x."</td><td align='center'> + </td><td>".$y."</td><td>".$z."</td>";
                  $c=0;
               }
            elseif ($z == 0)
               {
                  "<td>".$x."</td><td align='center'> + </td><td>".$y."</td><td> Error! </td>";
               }
            else
               {
                  echo "<td>".$x."</td><td align='center'> + </td><td>".$y."</td><td>".$z."</td>";
               }
            $k++;
            $c++;
         }
      ?>
         </tr>
      </table>
   </body>
</html>

Well its kinda similiar to my last code issue here but i made sure to not repeat that mistake xP
link to actual page: Here
Back to top Go down
Old Amsterdam
Bow Before Thy Master
Bow Before Thy Master
avatar

Join date : 2010-03-04
Rank : Head Admin / Site Owner

Posts : 7269


PostSubject: Re: Issues with breaks   Tue Mar 16, 2010 9:33 am

Couple issues I noticed right off the bat looking at the page. You have
Code:
<td align='center'> + </td>
but it needs to be
Code:
 <td align='center'> [color=red]/[/color]</td>
For division.

Second, you are using a modulus (%) instead of a division for your $z. It needs to be
Code:
$z=$y / $x;
. A simple mistake, but a big problem.

Another thing I'd do would change your
Code:
if ($c == 1 && $z == 0)
to
Code:
if(($c == 1) AND ($z == 0))
.

Another thing that is messed up is that you aren't ever actually ending the TR and starting a new one. I'd change that if to be the switch variable and have it reset $c, like how Gardner explained it yesterday.

Change that stuff and we'll see if it's still messed up.

_________________
As authors, it is our Duty
To create lovable, enticing Characters
And do horrible, evil things to Them.

Back to top Go down
http://battlezone.forumotion.net/
 

Issues with breaks

View previous topic View next topic Back to top 

 Similar topics

-
» iOS6 Update Issues
» 7th Kingdom
» Eaglemoss Star Trek die-cast starships collection
» Trollking Random Weekly topics/Issues
» Poqery and Reconnecting Issues
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Battle Zone :: Extra! Extra! :: Random-
Jump to: