php - mysql jump first row while insert data -


can kindheart give me short explanation this?

<?php  $selection = query("select * rows_test");  /* query() abbreviation of mysqli_query();*/  $num_rows = mysqli_num_rows($selection);  $row_id = '';  $row_string = '';  if(isset($_post['submit'])){  for($row_id=1; $row_id<=$num_rows; $row_id++){      $row_string = 'row-' . date('y') . '-' .$row_id;  }   $sql  = "insert rows_test (row_id, row_string) "; $sql .= "values ('{$row_id}','{$row_string}')";  $result = query($sql); confirm_query($result); /*test if there result*/   }   ?>  <form action="" method="post">     <input type="submit" name="submit" value="button" /> </form> 

with code php insert in table first row_string empty , row_id =1 (i because assign value row_id in loop).. after first works fine expect table id=2 start want. need row_id same table id(that of course auto increment).

by way know there's way without row_id i'm testing other ways things.

try

for($row_id=0; $row_id<$num_rows; $row_id++){ 

Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -