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

  • SEARCH
  • Home
  • 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 9156833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:51:55+00:00 2026-06-17T12:51:55+00:00

I am using this code for storing values in database ,but when i select

  • 0

I am using this code for storing values in database ,but when i select multiple check-box only one eid value is getting stored in database ( which should be no of checkbox i have selected) and also rid value is stored as 0
where is the mistake?
this is php code

<?php //insert selected candidate in table                  
                    //echo "checkcandi".$_POST['check_candi']; 
if(isset($_POST['select_candidate']) && logged_in())
{
  $checkcandi_sel = $_POST['check_candi'];
  if(empty($checkcandi_sel)) 
  {
    echo("You didn't select any Candidates.");
  } 
  else
  {
    $N = count($checkcandi_sel);

    echo("You selected $N Candidate(s): ");
    for($i=0; $i < $N; $i++)
    {
      echo($checkcandi_sel[$i] . " ");
      $eid=$checkcandi_sel[$i];
       echo "candi id".$eid;
    }
  }

//$rid=$value[1];
if(logged_in())
    {
    $emplyrid=$_SESSION['uid'];
    echo "emplyrid".$emplyrid;
    }
//$rid=$_GET['rid'];
//var_dump($emplyrid);
$query = "INSERT INTO selected_candidate (
                            eid,rid
                        ) VALUES (
                             '{$eid}','{$emplyrid}'
                        )";
            $result = mysql_query($query, $connection);
            if ($result) {
                $message = "<p style=\"color:green\">The Candidate selected and saved to your my seleted.</p>";
            } else {
                $message = "Sorry job was not applied.";
                $message .= "<br />" . mysql_error();
            }
}


?>

this is code for check-box

echo "<td><input id=\"select_candi{$i}\" onclick=\"javascript:func(this.id,{$_SESSION['uid']})\" type=\"checkbox\" name=\"check_candi[]\" value=\"{$data_set['eid']}\"/></td>"; 
  • 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-06-17T12:51:56+00:00Added an answer on June 17, 2026 at 12:51 pm

    Pull your for loop near insert query and try this,

    $N = count($checkcandi_sel);
    
    if($N > 0) {
      for($i=0; $i < $N; $i++)
      {
        $eid=$checkcandi_sel[$i];
        $query = "INSERT INTO selected_candidate (
                            eid,rid
                        ) VALUES (
                             '{$eid}','{$emplyrid}'
                        )";
        $result = mysql_query($query, $connection);
    
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Sqlite database and storing empty values for rows.I am using this
I am using this code to pull my string array from my values folder:
I'm using this code to read the connection string from my app.config file but
I want to insert multiple selected values into database in listbox. I am using
Im using this code: protected String getContactInfo() { Cursor cursor = getContentResolver().query(ContactsContract.Data.CONTENT_URI, null, null,
I'm compressing a string with Gzip using this code: public static String Compress(String decompressed)
Background I serialize a very large List<string> using this code: public static string SerializeObjectToXML<T>(T
I'm using this code inside WPF application: public static string EncryptString(string stringToEncrypt) { SHA256
I'm using this code: public static MjpegInputStream read(String url) { HttpResponse res; DefaultHttpClient httpclient
I am using this code for on android just trying to convert string to

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.