Solved: PHP not counting correctly

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

namenotfound

Thread Starter
Joined
Apr 30, 2005
Messages
3,012
On one of my pages I list items, and for each item I add a bit of PHP so I can quickly total up the items at the end.

Example:

a
b
c
d
e
f
g

"I have 7 items"

The PHP looks like this:

<?php $x++;?>a
<?php $x++;?>b
<?php $x++;?>c
<?php $x++;?>d
<?php $x++;?>e
<?php $x++;?>f
<?php $x++;?>g

<?php echo "<div class='center'>I have <b>$x</b> items.</div> \n"; ?>

It will list it as "10 items" instead of "7 items"

Why would it be adding +3 to the number?

Also, if you have a better way of doing this, please let me know.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top