mysql - Getting data from POST [id] form in PHP -


on table displays data database, have form has text area on user can type receipt number , submit save in database specif row. php code below updates database after form submitted. want pick rest of details specific row used $_post['id'] on receipt has been submitted. id primary key. i'm having challenge since can't fetch data database using $id = $_post['id'];i created before outside function update statement works select statementdoesn't . how go it? one?

if(isset($_post['submit'])) {  $rec = $_post['receipt']; $id = $_post['id']; //reate connection  $sql = "update customer set `receipt` = '".$_post['receipt']."', `date_entered` = now(), `receipt_lock` = 1 `id` = '".$_post['tid']."' , receipt_lock = 0";    if ($conn->query($sql) === true) {      // echo "new record created successfully";    } else {       echo "error: " . $sql . "<br>" . $conn->error;       exit();     $conn->close(); }   function wall(){  global $recp; global $id;  // create con  $sql = "select * customer id ='$id'";   $result1 = mysqli_query($conn, $sql);         $resultarr = mysqli_fetch_assoc($result1); // fetch data                   $name = $resultarr['name'];                 echo "$name"; //does not display                  $amount = $resultarr['amount'];                 $transaction_id = $resultarr['trans_id'];                 $date = $resultarr['time_paid'];     } else {  echo "this not right!; } wall(); 

ignoring (valid) questions sql security , addressing problem - how passing $id variable parameter wall function.?

wall($id);  function wall($id){      $sql = "select * customer id ='$id'";     // ... use prepared statements security...     ... } 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -