mardi 30 mai 2017

Simple passing of input to a button onClick

So i'm creating a taxi booking app ( mock-up project ) and am implementing a search bar for searching through a database via sql. I've got everything working, but now i want to check if a code is valid in the table, before assigning a taxi driver to it.

$sql = "UPDATE cabBookings SET _status = 'assigned' WHERE _booking_code = '$code'";
$sqlTwo = "SELECT * FROM cabBookings WHERE _booking_code = '$code'";

if($result = @mysqli_query($connection, $sqlTwo)){
        if($result->fetchColumn() > 0){
            if (@mysqli_query($connection, $sql)) {
                echo "<p style = 'padding: 10px; background-color: #8ae57b; border: 1px solid black; max-width: 400px;'>Great! Thankyou
                    for taking up your time. You have been assigned the duty of picking up this passenger :-)</p>
                    <button style = 'margin-top: 10px;' type = 'button' onClick = 'location.reload()'>Reload Page</button>";
            } else {
                echo "Error: " . $sql . "<br>" . $connection->error;
            }
        }else{
            echo "<p style = 'padding: 10px; background-color: #ed6c63; border: 1px solid black; max-width: 400px;'>Sorry, the code
                    you have entered is not a current booking</p>"
        }
    }

obviously the code isn't working, and i was just wondering what i am doing wrong




Aucun commentaire:

Enregistrer un commentaire