The edit form should display the string database values

I want my edit form to display already saved values ​​in the DB. And then the user can change / update these values. Below is my code. I'm not sure what I am doing wrong here. It looks like my echo call is not working. Any help is appreciated!

<!doctype HTML>
<head>
    <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jqβ€Œβ€‹uery-ui.css">
    <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">

</head>
<body>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.js"></script>

    <?php




    include 'includes/head.php'; 
    include 'ven_connect.php';
    include "dashboard.php";


    if (isset($_GET["page"])) 
    { 
        $page  = (int) $_GET["page"]; 
    } 
    else 
    { 
        $page=1; 
    }; 
    $start_from = ($page-1) * 4; 

    $result = mysqli_query($conn , "SELECT * FROM vendor LIMIT $start_from, 4") or die (mysqli_error ($conn));

    echo "<table title='Vendors'>";
    echo '<tr>';
    echo    "<th>Sr</th>";
    echo    "<th>Edit</th>";
    echo    "<th>Delete</th>";
    echo    "<th>Name</th>";
    echo    "<th>PhoneNo</th>";
    echo    "<th>Email</th>";
    echo "</tr>";
    echo "<tr>";
    while($row = mysqli_fetch_array( $result )) {

        // display the contents of each row into a table
        echo "<tr>";
        echo '<td>' . $row['id'] . '</td>';
        echo '<td>' . '<img src="edit.png" style = "height:35px;margin-left :8px;" id="abc">' . '</td>';
        echo '<td>' . '<img src="delete.png" style = "height:35px;margin-left :8px;" onclick = "deleterecord('.$row['id'].')">' . '</td>';
        echo '<td>' . $row['Name'] . '</td>';
        echo '<td>' . $row['Number'] . '</td>';
        echo '<td>' . $row['email'] . '</td>';
        echo "</tr>"; 
    } 
    echo "</tr>";
    echo '<div id="dialog-confirm" style="display:none;">';
        echo'<form method="post"  action="edit_ven.php"  class="ajax">';
            echo'<label for="id">ID</label>';
            echo'<input type="number" id="id" name="id" value="<?php echo '.$row['id'].'; ?>" readonly>  ';    
            echo'<label for="name">Name</label>';
            echo'<input type="name" id="name" name="name" value="<?php echo '.$row['Name'].'; ?>">';
            echo'<label for="number">Number</label>';
            echo'<input type="number" id="number" name="number" value="<?php echo '.$row['Number'].'; ?>">';
            echo'<label for="email">Email</label>';
            echo'<input type="email" id="email" name = "email" value="<?php echo '.$row['email'].'; ?>">';
            echo'<input type="submit" id="update" value="Submit">';
            echo'<input type="submit" id="cancel" value="Cancel">';
        echo'</form>';
    echo'</div>';
    echo "</table>";





    //Pagination!!  
    if($page > 1)
    {

        $prev= $page - 1;

        echo " <a href='{$_SERVER['PHP_SELF']}?page=$prev'>Prev</a> ";
    }
    $result = mysqli_query($conn , "SELECT * FROM vendor") or die (mysqli_error ($conn));
    $total_records = mysqli_num_rows($result); 
    $total_pages = ceil($total_records / 4); 

    $range = 3;


    for ($x = ($page - $range); $x <($page + $range); $x++) {

        if (($x > 0) && ($x <= $total_pages)) {

            if ($x == $page) {

                echo " [<b>$x</b>] ";

            } 

            else {

                echo " <a href='{$_SERVER['PHP_SELF']}?page=$x'>$x</a> ";
            } 
        } 
    } 
    if($page != $total_pages)
    {
        $nextpage=$page+1;
        echo " <a href='{$_SERVER['PHP_SELF']}?page=$nextpage'>Next</a> ";
    }






    ?>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
    <script src="smoke.js"></script>
    <link rel="stylesheet" href="css/venview.css">
    <script type="text/javascript">
        function deleterecord ( id ) {
            smoke.confirm("Do you want to delete?", function(result){
                if(result)
                {
                    window.location.href = 'delete_ven.php?id=' + id;
                }
                else{
                    header("Location: ven_view.php");
                }});

        }
        $(document).ready(function(){
            $("#abc").click(function() {
                $('#dialog-confirm').dialog({
                    modal: true,
                    width: 400,
                    height: 400
                });
            });
        });

    </script>


</body>

</html>

      

+3


source to share


1 answer


Your div confirmation dialog is in your while loop, so your variable is not available.



0


source







All Articles