Jump to content



Photo

cant wrap my head around this

php

  • Please log in to reply
3 replies to this topic

#1 SPEhosting

SPEhosting

    C++ n00b

  • Tech Issues Solved: 1
  • Joined: 15-July 08
  • Location: my room
  • OS: windows 7, backtrack 5, OSx 10.6

Posted 17 December 2012 - 16:20

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



#2 Guth

Guth

    Alba Gu Bráth

  • Joined: 30-December 05
  • Location: Scotland
  • OS: Windows 8 Pro
  • Phone: iPhone 5

Posted 18 December 2012 - 15:33

<head>
this
</head>

sorry :laugh:

#3 OP SPEhosting

SPEhosting

    C++ n00b

  • Tech Issues Solved: 1
  • Joined: 15-July 08
  • Location: my room
  • OS: windows 7, backtrack 5, OSx 10.6

Posted 19 December 2012 - 03:26

<head>
this
</head>

sorry :laugh:


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

#4 OP SPEhosting

SPEhosting

    C++ n00b

  • Tech Issues Solved: 1
  • Joined: 15-July 08
  • Location: my room
  • OS: windows 7, backtrack 5, OSx 10.6

Posted 19 December 2012 - 04:04

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]) <img src='http://www.neowin.net/forum/public/style_emoticons/<#EMO_DIR#>/biggrin.png' class='bbc_emoticon' alt=':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);
   }

TADA!!



Click here to login or here to register to remove this ad, it's free!