Click here to Skip to main content
15,566,520 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
<?php 
    require_once('db.php'); 
    $select = "SELECT `id`, `name`, `mail`, `text` FROM `team`";
    $query = mysqli_query($db, $select);
    $team = mysqli_fetch_all($query, MYSQLI_ASSOC);

    if($query) {?>
        <style>
            td {
                padding: 10px;
                background: #000;
                color: #fff;
            }
            form {
                margin-top: 10px;
                display: flex;
                flex-direction: column;
            }
            input,
            button {
                margin-top: 5px;
                width: 300px;
                border-radius: 5px;
            }
            a {
                text-decoration: none;
                color: inherit;
                transition: all 0.6s ease 0s;
            }
            a:hover {
                transition: all 0.6s ease 0s;
                text-decoration: underline;
            }
        </style>
        <h2>Table Members</h2>
        <table>
            <thead>
                <td>ID</td>
                <td>NAME</td>
                <td>MAIL</td>
                <td>DESCRIPTION</td>
                <td>DELETE</td>
                <td>EDIT</td>
            </thead>
        <?php foreach($team as $member){?>
            <tr>
                <td><?php echo $member[id] ?></td>
                <td><?php echo $member[name] ?></td>
                <td><?php echo $member[mail] ?></td>
                <td><?php echo $member[text] ?></td>
                <td><a href="delete.php?member_id=<?php echo $member[id]?>">Delete</a></td>
                <td><a href="index.php?edit_id=<?php echo $member[id]?>">Edit</a></td>
            </tr>
        <?php } ?>
            </table>
        <?php if(!empty($_GET['edit_id'])){?>
            <form action="edit.php" method="POST">
                <?php 
                    foreach($team as $member) {
                        if($member['id'] == $_GET['edit_id']) {?>
                            <label for="name">Edit name of member</label>
                            <input type="text" id="name" name="name" value="<?php echo $member['name'] ?>">
                            <label for="mail">Edit mail of member</label>
                            <input type="text" id="mail" name="mail" value="<?php echo $member['mail'] ?>">
                            <label for="text">Edit description</label>
                            <input type="text" id="text" name="text" value="<?php echo $member['text'] ?>">
                        <?php}
                    }?>
                <input type="hidden" id="id" name="id" value="<?php echo $_GET['edit_id'] ?>">
                <button type="submit">Submit</button>
            </form>
        <?php } else {?>
            <form action="add.php" method="POST">
                <label for="name">Write name of member</label>
                <input type="text" id="name" name="name">
                <label for="mail">Write mail of member</label>
                <input type="text" id="mail" name="mail">
                <label for="text">Write description</label>
                <input type="text" id="text" name="text">
                <button type="submit">Add</button>
            </form><?php
        }
    }


What I have tried:

Parse error: syntax error, unexpected end of file in C:\wamp64\www\php\form.php on line 83
Posted
Comments
Afzaal Ahmad Zeeshan 29-Nov-22 17:43pm    
You have an open PHP tag in the file that causes the compiler to assume more code is incoming. You should use a PHP linter.

https://github.com/overtrue/phplint
Member 15627495 30-Nov-22 1:07am    
don't forget to close all instructions lines php with ";"
//
a php scope start by
"<?php ...;;;;;;;;;"
and ends by
"?>"
Sandeep Mewara 2-Dec-22 11:50am    
You shouldn't put brackets directly close to the open/close php tag, but separate it with a space:

{ ?>
<?php {

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900