• 0

cant wrap my head around this


Question

Im helping a friend with this and i cannot wrap my head around the logic ... I can see the problem... but basically its just not updating it correctly cause of some array comparing issues .. its hard to explain the problem but its fairy obviously when you look (it does update just you have to tick all the boxes or it updates to the previous one...


$nextedit;
$modCount = count($_POST['modify']);
if (isset($_POST['modify'])) {
for ($i = -1;$i<$modCount;$i++){



$mod = $_POST['modify'][$i];
$ids = $_POST['ids'][$i];
if ($mod != $ids)
{
$nextedit = $mod;
echo $nextedit;
} else if ($nextedit == $mod) {

$CAR_IDS= $_POST['CAR_IDS'][$i]; $car_names = $_POST['carnames'][$i];
$fuel_types = $_POST['fuel_types'][$i];
$transmissions = $_POST['transmissions'][$i];
$engine_sizes= $_POST['engine_sizes'][$i];
$doors = $_POST['doors'][$i];
$totals= $_POST['totals'][$i];
$availables =$_POST['availables'][$i];
$DATE_ADDEDS =$_POST['DATE_ADDEDS'][$i];



$in = "UPDATE XYZ SET CAR_ID = '$CAR_IDS', car_name = '$car_names', fuel_type = '$fuel_types', transmission = '$transmissions', engine_size = '$engine_sizes', door = '$doors', total = '$totals', available = '$availables', DATE_ADDED = '$DATE_ADDEDS' WHERE id = '$mod'";
mysql_query($in);

echo "id --->> = ".$ids." working yet??"; }
}}
[/CODE]

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

just encase people are interested ... I set the update checkbox values as numbers (which were generated on the table via the loop) .... seeing as all the information was being sent at once the number would match the array position of the id you wanted to update ... so by.....


for ($u=0;$u<$upcou;$u++)
{
$m = $upd[$u]; //update values only sent if ticked... so counted the update posts then used the number to set for loop... the first one i wanted to update would be array 0 .... then the value of the posted update ($upd) would be used to select the array of $_POST i want ... ([$m]) :D amazing what a full nights sleep can do for the brain ..
$id = $_POST['id'][$m];
$carname = $_POST['carname'][$m];
$fueltype = $_POST['fueltype'][$m];
$transmission = $_POST['transmission'][$m];
$enginesize = $_POST['enginesize'][$m];
$doors = $_POST['doors'][$m];
$total = $_POST['total'][$m];
$available = $_POST['available'][$m];

$up = new manage($PDO);
$up->update($id, $carname, $fueltype, $transmission, $enginesize, $doors, $total, $available);
}
[/CODE]

TADA!!

Link to comment
Share on other sites

This topic is now closed to further replies.