How to auto increment an element when it is posted in php

I would like to know how to increase a element, each time that element is posted.

I have to use for loop for the auto increment, but i am not getting right. So any advise or guidance will be great.

Here is the way i have tried to do:

Thanks
[php]
$id=0;

if (isset($_POST[‘submit’])) {

$do = $_POST[‘prodCode’];

$di = count($do);

while ($di > $id) {

$id++;
echo $id;

}
}

?>

Session test

.holder
{
width: 700px;
height: auto;
margin: 20px auto 0 auto;
border: 2px solid #eee;
padding:10px;

}
.im{
width: 200px;
height: auto;
margin-left: 30px;
margin-right:20px;
margin-top: 80px;
padding: 10px;
border: 1px solid olive;
text-align: center;
display: inline-block;
}

.im img
{
border: 1px solid #ddd;
padding: 2px;
}

bestorange-juice

bestorange-juice

[/php]

Please use the code tags. You have been here long enough to know how to use them.

Your issue is the prodCode. It is 1. So the loop will execute once. What are you expecting to happen?

Based on what you posted you will want to use SESSIONS to store your value to increment. Look up a simple SESSION page counter. The code is very close to what you want.

Sponsor our Newsletter | Privacy Policy | Terms of Service