can some kindheart give me a short explanation about this?
<?php
$selection = query("SELECT * FROM rows_test");
/* query() is an 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 INTO rows_test (row_id, row_string) ";
$sql .= "VALUES ('{$row_id}','{$row_string}')";
$result = query($sql);
confirm_query($result); /*Test if there is a result*/
}
?>
<form action="" method="post">
<input type="submit" name="submit" value="Button" />
</form>
With this code php insert in the table the first row_string empty and the row_id =1 (i get that this is because i assign the value for row_id in the for loop).. after the first then it works fine as i expect so from the table id=2 it start what i want. but i need that the row_id is the same as the table id(that is of course auto increment).
By the way i know there's a way to do without row_id but i'm just testing some other ways to do things.