2

I'm trying to insert sql ID record inside php echo form input value. Values that are inserted manualy via input field (by typing) are being displayed fine. Value inside input (named: potnik) is not being displayed. Is it ignored because is inside echo or is inserted wrong?

$sql3 = "
SELECT id, potnik_id, ura, naslov
FROM prevoznik 
ORDER BY HOUR(ura), MINUTE(ura) ASC;
";
$result = $conn->query($sql3);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {

        //Spremenjena oblika datuma
        $date = date_create($row["ura"]);
        $ura_pobiranja = date_format($date,"H:i");
        echo "<div class=\"row list  divider-gray\">
                <div class=\"col-1 fs-09 fw-600\">" . $row["id"] . " </div>
                  <div class=\"col-3 flex-vcenter-items fw-600 fs-09\">" . $row["naslov"] . " </div>
                <div class=\"col-1 flex-vcenter-items fw-600 fs-09\">$ura_pobiranja</div>
            ";

        if ($row["naslov"] !== null) {
            echo " <div class=\"col-6 flex-vcenter-items fs-1\">Nastavi uro<form action='update.php?id=" . $row["id"] . "\"' method='POST'><input name=\"potnik\"  value='".$row["id"]."' type='hidden' /> <input class=\"form-control fancy-border\" type=\"text\" name=\"posodobljeni_cas\"/><input type='submit' value='Posodobi'>  </form></div>";
            echo " </div>";
        }
        else {
            echo " </div>";
        }

    }
} else {
    echo "<div class=\"col flex-vcenter-items fw-100 fs-1\"><i class=\"far fa-frown-open pr-3\"></i>Nimaš še nobenih opravil
                                    </div>";
}

Code that isn't working (hidden input field value):

echo " <form action='update.php?id=" . $row["id"] . "\"' method='POST'><input name=\"potnik\"  value='".$row["id"]."' type='hidden' /> <input class=\"form-control fancy-border\" type=\"text\" name=\"posodobljeni_cas\"/><input type='submit' value='Posodobi'>  </form></div>";
6
  • You have an extra \" after the form action Commented Sep 19, 2018 at 18:33
  • It was a typo, I removed \" and value in the hidden field is still not passing $row["id"] Commented Sep 19, 2018 at 18:37
  • How do you know that the value is not displayed correctly? Are ou inspecting the element via devtools or what? Commented Sep 19, 2018 at 18:40
  • I inserted custom condition inside update.php to throw me error, That error throws me nothing for that hidden input field and throws me value for manualy entered value at posodobljeni_cas. Commented Sep 19, 2018 at 18:45
  • @FelippeDuarte Also value "5" is visible if inspecting the element via devtools. Commented Sep 19, 2018 at 18:48

1 Answer 1

1

I had post parameters instead of get parameters set for update.php form action

update.php?id=

echo"Error on update ID:{$_GET['id']} POSODOBLJENI CAS:{$_POST['posodobljeni_cas']}";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.