Hey everyone,

Having a few problems:

  1. It's not populating the dropdown with all the entries (But in the delete function it is, which is a somewhat copy)
  2. It doesn't post the Employer name, the result I'm getting is "Editing user: BLANK"

Here is the code:

function JobBoard_admin_edit() 
            {

             echo "<h4> edit </h4>";
            ?>
            <form name="jobboard_form" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">
            <?php
                echo '<select name="ID">';

                $con_edit= mysqli_connect("localhost", "profiled_job","", "profiled_jobboard") or die(mysql_error());
                $sql="SELECT ID,Employer FROM details";
                $result =mysqli_query($con_edit,$sql);
                //$employer_id = $_POST['ID'];
                while ($data=mysqli_fetch_assoc($result))
                {

                    echo '<option value ="' . $data['Employer'] . '">'. $data['Employer'] . '</option>';
                    echo "</select>";
                }
                    echo "<p>";
                    echo "<input type='submit' value='Update User' name='updateuser'></p>"; 
                    echo "</form>";


                if(isset($_POST['updateuser']))
                    {
                        $emp = $employer_id;
                        $sql = (mysqli_query($con_edit, "SELECT * FROM details WHERE Employer = '$emp'"));
                            if($sql)
                            {
                                echo "Editing user:" . $emp . "<p>";
                            }   
                    else 
                    {
                            echo "Data Not found";
                            echo $emp;
                        }

                    }

                }

Thanks Prit, but what about the drop down not populating properly?

The Delete function works and it looks like this:

<form method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">  
                <select name='ID'>
                    <?php 
                        $con= mysqli_connect("localhost", "profiled_job","", "profiled_jobboard") or die();
                        $sql= "SELECT ID,Employer FROM details";
                        $result =mysqli_query($con,$sql);
                        while ($data=mysqli_fetch_assoc($result)){
                     ?>
                  <option value ="<?php echo $data['ID'] ?>"><?php echo $data['Employer'] ?></option>
                     <?php } ?>
                    </select>
                    <p>
                        <input type="submit" value="Delete User" name='delete'></p> 
                </form>

The last one uses ID and Employer.

The select tag ending should be outside the loop, DOH!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.