Hi,
This problem has been driving me crazy all day. I am relatively new to PHP. I basically am trying to populate a database with data from site users. I am using session variables to store their data temporarily as they navigate through the sign up process. A user will input how many 'categories' they wish to populate on page 1. Page 2 will then ask them to specify the details of each category. Eg Category 1: Title, Description, Amount. Category 2: Title, etc.
So far I have been able to do this, I now want to store what they have input in session variables. My thoughts were to take the number of categories they have sepcified and create that number of arrays using a loop. Each array will store the details on each category. My code is as follows:
$count=$_POST['count']; //Get how many categories were added
//Create an array for each category
for ( $counter = 0; $counter <= $count; $counter++){
${'Categoryarr'.$counter} = array();
};
for ( $counter = 0; $counter <= $count; $counter++){
$Categoryarr[$counter][1]=$_POST['amount_'.$count];
$Categoryarr[$counter][2]=$_POST['desc_'.$count];
$Categoryarr[$counter][3]=$_POST['title_'.$count];
};
When I output the code, I seems to have created the specified number of arrays, but has populated all of them with the same data from the last category. Does anyone know where I am going wrong?
Thanks,
Bernard