Sign in to follow this  
Followers 0

php cant wrap my head around this

4 posts in this topic

Posted

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??"; }

}}

Share this post


Link to post
Share on other sites

Posted

<head>

this

</head>

sorry :laugh:

3 people like this

Share this post


Link to post
Share on other sites

Posted

<head>

this

</head>

sorry :laugh:

..... -______- well played sir.... well played

1 person likes this

Share this post


Link to post
Share on other sites

Posted

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])  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!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.