CRUD U cannot get the ID and edit the Update

Asked

Viewed 190 times

0

Folks I need a light to unwind a TIMESHEET.

I have the following code.

<form method="post" action="includes/input.php">
    <button type="submit" class="btn btn-primary" onClick="send('login');" value="login" >Default</button>
    <button type="submit" class="btn btn-primary" onClick="send('break');" value="break" >Default</button>
    <button type="submit" class="btn btn-primary" onClick="send('breakout');" value="breakout" >Default</button>
    <button type="submit" class="btn btn-primary" onClick="send('logout');" value="logout" >Default  </button>
    </form> 

This form perfectly calls the pages. The problem is that the first Submit is an INSERT INTO that works perfectly by sending four dates to the bank via Mysqli with the NOW function().

$sql = "INSERT INTO registros (id, re, login, inbreak, outbreak, logout) VALUES ('', '$re', now(), now(), now(), now())";

The third column with the Now() function indicates the operator’s input time on the production line, the fourth column the break input and so on, I need help understanding how I perform the update of these columns, but I am unable to capture the ID to perform the update.

Follow the page code that would be for the update of the fourth column.

$id = mysqli_insert_id($link);
var_dump($id);$re = '';
$sql = "UPDATE registros SET breakin = NOW() WHERE id = $id;"

Thank you in advance.

1 answer

0

your

$id = mysqli_insert_id($link);

this wrong you need to insert the connection of db in the command

$id = mysqli_insert_id($con);
  • I’ll try, thank you.

  • Test result. This command expects only one argument. Warning: mysqli_insert_id() expects Exactly 1 Parameter, 2 Given in /opt/lampp/htdocs/time/break.php on line 9

  • forgive me missed the function, you should only include the connection , nothing else. right after the command mysqli_query($con,$sql); you can do the $id = mysqli_insert_id($con);

  • there was another post that I answered with the same problem as you: http://answall.com/questions/151395/pega-%C3%Baltimo-id-inserted-no-mysql-com-php

Browser other questions tagged

You are not signed in. Login or sign up in order to post.