Hello, not sure how to get around this.
Ive got 3 screens(pages):
1. Data entry (form) passes user info to screen 2.
2. Checks that required data is present. User can go back and make corrections or submit if ok.
3. Inserts data into database.
There are two table to populate, so two insert statements.
The first insert works fine as its only inserting single values.
The problem lays with the second as it inserts multiple record based on the users selection from an array (checkboxes).
Ive managed to get this to work if I leave it on screen2. Problem here is it inserts on load which isnt very useful. I'd like to know if theres a way of passing the array '$thing' to the next page. So far I've had no success.
Heres the code from screen 2 that shows what users have selected:
else
foreach ($ascategory as $key)
{
// Do query to get existing categories from table 'category', check result for error
$sql3="select cid, category from category where cid='$key'";
$result3=mysql_query($sql3) or die("Problem with query: ".sql_error());
while($row=mysql_fetch_array($result3))
{
$cid=$row["cid"];
$category = $row["category"];
$category = stripslashes($category);
$category = ucwords($category);
echo "<em>$category</em>";
echo "<br>";
$thing[]=$row["cid"];
}
//echo $key . "<br>";
}
and heres the insert statement on the same page:
$counter=sizeof($thing);
for ($i=0; $i < $counter; $i++)
// {echo "$thing[$i]";}
{
$sql6="INSERT INTO solcat VALUES(NULL, '$identifyer', '$thing[$i]')";
print"$sql6";
$result6=mysql_query($sql6);
if(!$result6) echo "There has been an problem connecting to the database. Error: " . (sql_error());
}
I've tried sticking the insert within an 'isset' statement but that just doesnt work.
and I've tried passing '$counter' and '$thing' to the third page where although '$counter' works ok '$thing' only produces the word array not the value. I've used the same isert statemet on page three and page two.
Any help will be appreciated.
Any further clarification will be given if asked for.