Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6015349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:49:25+00:00 2026-05-23T02:49:25+00:00

i have a dynamically field that have a maximum of 4 inputs. If i

  • 0

i have a dynamically field that have a maximum of 4 inputs.

If i write 4 inputs that exists in the database i get

   input0 company // $num0
   "error" =  $num1
   input1 company // $num2
   "error" =  $num3
   input2 company // $num4
   "error" =  $num5
   input3 company // $num6

But if not exists in the database the order of first input is changed because the while is not played:

   "error" =  $num0
   input1 company // $num1
   and the order is changed....//problem

the main problem is that i need to know what is the input that exists in the database or not.

script

 function checkEmployeer($db, $form) {  
        $i=0;
        foreach ($form['job'] as $value) {

                $sql = $db -> prepare("SELECT `employer` FROM `employer` WHERE employer=?");

                $sql -> bind_param('s', $value);

                $sql -> execute();

                while ($sql -> fetch()) { //problem
                    ${'num'.$i++} = $value; //problem - $num0 = $value if exists in DB
                }   

                ${'num'.$i++} = "error"; //problem - $num0 or $num1 = depends of while result...    
        }

        for ($i = 0; $i < sizeof($form['job']); $i++) {

            if (${'num'.$i} != "error" && ${'num'.$i} == $form['job'][$i]) {
                echo ("already exists in the db".$i);
            }
            else {
                $sql = $db -> prepare("INSERT INTO `database_charts`.`employer` (`employer`) VALUES (?)"); 

                $sql -> bind_param('s', $form['job'][$i]);

                $sql->execute();    
                echo ("insert");
            }
        }   
    }

how i can solve that? i don’t have any idea…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:49:26+00:00Added an answer on May 23, 2026 at 2:49 am

    Create a key for employer and INSERT it without checking anything, affected_rows() will tell you if it has been inserted or not.
    You will not get duplicates if database_charts.employer is defined as key.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query that is dynamically built after looking up a field list
I have a field that is dynamically being filled. I know that the first
I have a form that hides a text input field dynamically, depending on the
I have 3 HTML form inputs fields that is dynamically generated by a add
I have a select field that is dynamically populated with an ajax call that
I have dynamically generated code like the following: <div class=message-error error>The Message field is
I have a form with field names that are generated dynamically by server side
I have a page that has fields dynamically loaded via JQuery. It allows a
I have some dynamically created inputs which are not server-side controls. I want to
I have a dynamically created image that I am saving to a stream so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.