I'm building a form on the fly and have 2 variables display[] and id[].
I pass these to another page and want to loop through the 2 arrays and build some SQL statements on the fly.
What I have noticed however is that when I alter the details on the form the one altered on the form is not neccesarrily the one altered when I come to echo my SQL on screen.
I guess its because I'm not looping through the array correct, any one got any ideas?
$count_id = count($id); // Count ID Array
$i = 0; // Set Counter Variables - use same as both arrays are the same size
// Iterate through the arrays and update on the fly
for($i; $i < $count_id; ++$i){
if($display[$i] == ""){
$display[$i] = 0;
}
$sql = "UPDATE profile SET Display = " .$display[$i]. " WHERE ID = ".$id[$i];
echo $sql ."<br>";
$sql_result = mysql_query($sql) or die(mysql_error());
}
echo "Profile options updated";
}