Hey guys,

So close to the end with this!

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)
                        {
                            $editvalue = mysqli_fetch_assoc($sql);  
                            echo '<form name="Form" action="' . str_replace( '%7E', '~', $_SERVER['REQUEST_URI']) . '" method="post">';
                            echo'<input type="text" style="display:none;" name="ID" Value="' . 'test' . '"/>';
                            echo'<label>Employer:
                            <span class="small"></span>
                            </label>'; 
                            echo'<input type="text" name="Employer" value="' . $editvalue['Employer'] . '" /><br/><br>';
                            echo'<label>Learning Provider';
                            echo'</label> <input type="text" name="LearningProvider" value="' . $editvalue['LearningProvider'] . '"/><br>';
                            echo'<label>Contracted Provider';
                            echo'</label> <input type="text" name="ContractedProvider" value="' . $editvalue['ContractedProvider'] . '"/><br>';
                            echo'<label>Learning Delivery Site:';
                            echo'</label>  <input type="text" name="LearningDeliverySite" value="' . $editvalue['LearningDeliverySite'] .'"/><br>';
                            echo'<label>Vacancy Description:';
                            echo'</label> <textarea rows="5" Cols="22" type="text" name="VacancyDescription"/>' . $editvalue['VacancyDescription'] . '</textarea><br>';
                            echo'<label>Vacancy Title:';
                            echo'</label> <input type="text" name="VacancyTitle" value="' . $editvalue['VacancyTitle'] . '"/><br>';
                            echo'<label>Employer Description:';
                            echo'</label> <input type="text" name="EmployerDescription" value="' . $editvalue['EmployerDescription'] . '"/><br>';
                            echo'<label>Vacancy Location:';
                            echo'</label> <input type="text" name="VacancyLocation" value="' . $editvalue['VacancyLocation'] . '"/><br>';
                            echo'<label> Working Week Hours:';
                            echo'</label> <input type="number" name="WorkingWeek" value="' . $editvalue['WorkingWeek'] . '" /><br>';
                            echo'<label>Weekly Wage:';
                            echo'</label> <input type="text" name="WeeklyWage" value="' . $editvalue['WeeklyWage'] . '"/><br>';
                            echo'<label>Vacancies:';
                            echo'</label> <input type="text" name="NoVacancies" value="' . $editvalue['NoVacancies'] . '"/><br>';
                            echo'<label>Reference Number:';
                            echo'</label> <input type="text" name="VacancyRefNumber" value="' .  $editvalue['VacancyRefNumber'] .'" /><br>';
                            echo'<label>Closing Application Date:';
                            echo'</label> <input type="date" name="ClosingDateForApplications" value="' . $editvalue['ClosingDateForApplications'] . '"/><br>';
                            echo'<label>Interview Start Date:';
                            echo'</label> <input type="date" name="InterviewBeginFrom" value="' . $editvalue['InterviewBeginFrom'] . '"/><br>';
                            echo'<label>Possible Start Date:';
                            echo'</label> <input type="date" name="PossibleStartDate" value="' . $editvalue['PossibleStartDate'] . '"/><br>';
                            echo'<label>Training to be provided:';
                            echo'</label> <input type="text" name="TrainingToBeProvided" value="' . $editvalue['TrainingToBeProvided'] . '"/><br>';
                            echo'<label>Learning Provider Desc:';
                            echo'</label> <input type="text" name="LearningProviderDescription" value="' . $editvalue['LearningProviderDescription'] . '"/><br>';

                            echo'<input type="submit" value="Update User" name="update_submit" />';
                            if(isset($_POST['update_submit']))
                            {

                                $sql_edit = mysql_query("UPDATE details SET 
                                Employer='$_POST[Employer]',  
                                LearningProvider='$_POST[LearningProvider]',  
                                ContractedProvider='$_POST[ContractedProvider]',
                                LearningDeliverySite='$_POST[LearningDeliverySite]',
                                VacancyDescription='$_POST[VacancyDescription]',
                                VacancyTitle='$_POST[VacancyTitle]',
                                EmployerDescription='$_POST[EmployerDescription]',
                                VacancyLocation='$_POST[VacancyLocation]',
                                WorkingWeek='$_POST[WorkingWeek]',
                                WeeklyWage='$_POST[WeeklyWage]',
                                NoVacancies='$_POST[NoVacancies]',  
                                VacancyRefNumber='$_POST[VacancyRefNumber]',
                                ClosingDateForApplications='$_POST[ClosingDateForApplications]',
                                InterviewBeginFrom='$_POST[InterviewBeginFrom]',           
                                PossibleStartDate='$_POST[PossibleStartDate]',           
                                TrainingToBeProvided='$_POST[TrainingToBeProvided]',             
                                LearningProviderDescription='$_POST[LearningProviderDescription]',            
                                ContactDetails='$_POST[ContactDetails]',
                                VacancyType='$_POST[VacancyType]',
                                ApprenticeshipFramework='$_POST[ApprenticeshipFramework]', 
                                SkillsRequired='$_POST[SkillsRequired]',
                                PersonalQualities='$_POST[PersonalQualities]',           
                                ImportantOtherInformation='$_POST[ImportantOtherInformation]' WHERE ID = '$employer_id'");

                                if($sql_edit) {

                                    echo "Successful";


                                    } else {

                                    echo "error";


                                        }
                                    }
                                }
                            }
                        }       

            ?>

Sorry for the standards - Copied from WP itself.

Basically each isset redoes a form action and populates the page... the problem is it isn't updating, I can't see where the fault is as such...

Just wondering if a second pair of eyes could help?

Do you get "error" or "successful" ?

I get nothing. Just a blank page :P

Perhaps because update_submit is nested within updateuser?

Still not working :(

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","ZH8liJnG5pZR", "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)
                        {
                            $editvalue = mysqli_fetch_assoc($sql);  
                            echo '<form name="Form" action="' . str_replace( '%7E', '~', $_SERVER['REQUEST_URI']) . '" method="post">';
                            echo'<input type="text" style="display:none;" name="ID" Value="' . 'test' . '"/>';
                            echo'<label>Employer:
                            <span class="small"></span>
                            </label>'; 
                            echo'<input type="text" name="Employer" value="' . $editvalue['Employer'] . '" /><br/><br>';
                            echo'<label>Learning Provider';
                            echo'</label> <input type="text" name="LearningProvider" value="' . $editvalue['LearningProvider'] . '"/><br>';
                            echo'<label>Contracted Provider';
                            echo'</label> <input type="text" name="ContractedProvider" value="' . $editvalue['ContractedProvider'] . '"/><br>';
                            echo'<label>Learning Delivery Site:';
                            echo'</label>  <input type="text" name="LearningDeliverySite" value="' . $editvalue['LearningDeliverySite'] .'"/><br>';
                            echo'<label>Vacancy Description:';
                            echo'</label> <textarea rows="5" Cols="22" type="text" name="VacancyDescription"/>' . $editvalue['VacancyDescription'] . '</textarea><br>';
                            echo'<label>Vacancy Title:';
                            echo'</label> <input type="text" name="VacancyTitle" value="' . $editvalue['VacancyTitle'] . '"/><br>';
                            echo'<label>Employer Description:';
                            echo'</label> <input type="text" name="EmployerDescription" value="' . $editvalue['EmployerDescription'] . '"/><br>';
                            echo'<label>Vacancy Location:';
                            echo'</label> <input type="text" name="VacancyLocation" value="' . $editvalue['VacancyLocation'] . '"/><br>';
                            echo'<label> Working Week Hours:';
                            echo'</label> <input type="number" name="WorkingWeek" value="' . $editvalue['WorkingWeek'] . '" /><br>';
                            echo'<label>Weekly Wage:';
                            echo'</label> <input type="text" name="WeeklyWage" value="' . $editvalue['WeeklyWage'] . '"/><br>';
                            echo'<label>Vacancies:';
                            echo'</label> <input type="text" name="NoVacancies" value="' . $editvalue['NoVacancies'] . '"/><br>';
                            echo'<label>Reference Number:';
                            echo'</label> <input type="text" name="VacancyRefNumber" value="' .  $editvalue['VacancyRefNumber'] .'" /><br>';
                            echo'<label>Closing Application Date:';
                            echo'</label> <input type="date" name="ClosingDateForApplications" value="' . $editvalue['ClosingDateForApplications'] . '"/><br>';
                            echo'<label>Interview Start Date:';
                            echo'</label> <input type="date" name="InterviewBeginFrom" value="' . $editvalue['InterviewBeginFrom'] . '"/><br>';
                            echo'<label>Possible Start Date:';
                            echo'</label> <input type="date" name="PossibleStartDate" value="' . $editvalue['PossibleStartDate'] . '"/><br>';
                            echo'<label>Training to be provided:';
                            echo'</label> <input type="text" name="TrainingToBeProvided" value="' . $editvalue['TrainingToBeProvided'] . '"/><br>';
                            echo'<label>Learning Provider Desc:';
                            echo'</label> <input type="text" name="LearningProviderDescription" value="' . $editvalue['LearningProviderDescription'] . '"/><br>';
                            echo'<input type="submit" value="Update User" name="update_submit" />';
                                }
                            if(isset($_POST['update_submit']))
                            {
                                $sql_edit = mysql_query("UPDATE details SET 
                                Employer='$_POST[Employer]',  
                                LearningProvider='$_POST[LearningProvider]',  
                                ContractedProvider='$_POST[ContractedProvider]',
                                LearningDeliverySite='$_POST[LearningDeliverySite]',
                                VacancyDescription='$_POST[VacancyDescription]',
                                VacancyTitle='$_POST[VacancyTitle]',
                                EmployerDescription='$_POST[EmployerDescription]',
                                VacancyLocation='$_POST[VacancyLocation]',
                                WorkingWeek='$_POST[WorkingWeek]',
                                WeeklyWage='$_POST[WeeklyWage]',
                                NoVacancies='$_POST[NoVacancies]',  
                                VacancyRefNumber='$_POST[VacancyRefNumber]',
                                ClosingDateForApplications='$_POST[ClosingDateForApplications]',
                                InterviewBeginFrom='$_POST[InterviewBeginFrom]',           
                                PossibleStartDate='$_POST[PossibleStartDate]',           
                                TrainingToBeProvided='$_POST[TrainingToBeProvided]',             
                                LearningProviderDescription='$_POST[LearningProviderDescription]',            
                                ContactDetails='$_POST[ContactDetails]',
                                VacancyType='$_POST[VacancyType]',
                                ApprenticeshipFramework='$_POST[ApprenticeshipFramework]', 
                                SkillsRequired='$_POST[SkillsRequired]',
                                PersonalQualities='$_POST[PersonalQualities]',           
                                ImportantOtherInformation='$_POST[ImportantOtherInformation]' WHERE ID = '$employer_id'");
                                if($sql_edit) {
                                    echo "Successful";
                                    } else {
                                    echo "error";
                                        }
                                    }
                            }
                        }       
?>

It's still nested.

Ahh derp.

Ok it now returns error. Is there a way I can check the error?

Error log is empty

mysql_error()

"Errormessage:"

  if($sql_edit) {
                    echo "Successful";
                } else {
                    printf("Errormessage: %s\n", mysqli_error($con_edit));
                }

sql_edit ... not con_edit

tis a blank message aswell :(

Mixing MySQL and MySQLi again...

Any reason why you don't use the wp-build-in database class: $wpdb?

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.