简体   繁体   中英

Form button not displaying (php)

extraction from code:

The edit buttons are not visible on the webpage. not sure why? Was working and I only added the [$eventid] section. removed it and it's still not working. Tried using a different browser and still not working.

    <div class="current events">
        <h1>Your Current Events:</h1>
        <?php

        $sql = "SELECT * FROM events WHERE userid='{$_SESSION['u_id']}';";
        $result = mysqli_query($conn, $sql);
        if (mysqli_num_rows($result) > 0){
            while ($row = mysqli_fetch_assoc($result)){
                echo "<b>Event name: </b>";
                echo " ";
                echo $row['eventname'];
                echo " ";
                echo "<b>Event Venue: </b>";
                echo " ";
                echo $row['venue'];
                echo " ";
                echo "<b>Event Date: </b>";
                echo " ";
                echo $row['date'];
                echo "<p></p>";


                "
                    <form class='edit-btn' method='POST' action='editevent.php'>
                        <input type='hidden' name='eventname' value='" .$row['eventname']. "'>
                        <input type='hidden' name='venue' value='" .$row['venue']. "'>
                        <input type='hidden' name='date' value='" .$row['date']. "'>
                        <input type='hidden' name='name' value='" .$row['name']. "'>
                        <input type='hidden' name='eventid' value='" .$row['eventid']. "'>

                        <button>Edit</button>

                    </form>


                ";

            }
        }else{
            echo "No Upcoming Events";
        }

        ?>
    </div>

You forget to echo the form content.As it in in php you must have to echo

 echo "
                    <form class='edit-btn' method='POST' action='editevent.php'>
                        <input type='hidden' name='eventname' value='" .$row['eventname']. "'>
                        <input type='hidden' name='venue' value='" .$row['venue']. "'>
                        <input type='hidden' name='date' value='" .$row['date']. "'>
                        <input type='hidden' name='name' value='" .$row['name']. "'>
                        <input type='hidden' name='eventid' value='" .$row['eventid']. "'>

                        <button>Edit</button>

                    </form>


                ";

Firstly, include an "echo", before declaring the form in double quotes. And for the button case, you may try doing it with input. Like, . Hopefully it will work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM