php - variable the loop doesn't increase -


need count updated data in table, $up stays 0. data received imported csv file.

$up=0;        { //loop through csv file             if ($data[0]) {                 $res = mysql_query("select ...");                 $check=false;                 for($i = 0; $array[$i] = mysql_fetch_assoc($res); $i++){                      while ((condition)){                             $check = true;                             $i++;                     };                 };             if ($check) {                 $up++;//this not work                 mysql_query("update ...");              }             else {                 mysql_query("insert ...");              }             }         } while ($data = fgetcsv($handle,1000,",","'")); 

there's code below do-while loop choose file , messege $up

<html> ... <?php if (!empty($_get[success])) {echo $up; } ?>  <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">    choose file: <br />    <input name="csv" type="file" id="csv" />    <input type="submit" name="submit" value="submit" />  </form>  ... 

from can see, i'm pretty sure inserting , not updating.

your $up executed in cas $check true , $check true if every line in query meets (condition)

you should verify doing in while(condition)

              for($i = 0; $array[$i] = mysql_fetch_assoc($res); $i++){                  while ((condition)){                         $check = true;                         $i++;                 };             }; 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -