0

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;
                        }

                    }

                }
2
Contributors
4
Replies
26
Views
4 Years
Discussion Span
Last Post by pritaeas
0

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>

Edited by pritaeas: Removed password.

0

The last one uses ID and Employer.

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

Edited by pritaeas

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.