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 8618787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:11:28+00:00 2026-06-12T06:11:28+00:00

guys im trying to make a list of students in php and getting each

  • 0

guys im trying to make a list of students in php and getting each of its value and insert it in the database.

$b_lname = $_POST['bstudnt_lname'];
$b_fname = $_POST['bstudnt_fname'];
$b_mname = $_POST['bstudnt_mname'];

$department = $_POST['class_department'];
$section = $_POST['section_name'];
$year_grade = $_POST['faclty_advse_year'];

$school_id ="a3arew542q3dq";

$counter2 = 0;

$button = $_POST['add_students'];

if(isset($button)){

    foreach($b_lname as $blast => $x){ 
        $arraylname[] ="".$x;
        }  
    foreach($b_fname as $bfirst => $y){
            $arrayfname[] ="".$y;
            $counter2+=1;
        }
    foreach($b_mname as $bmid => $z){
            $arraymname[] ="".$z;
            $counter2+=1;
        }   



        for($v=0;$v<=$counter2-1;$v++){

            if($arrayfname[$v]!="" && $arraymname[$v]="" &&   $arraylname[$v]=""){

            $insert = "INSERT INTO  students(school_id,firstname,middlename,lastname,gender,department,section,year_grade) 
           VALUES('$school_id','$arrayfname[$v]','$arraymname[$v]','$arraylname[$v]','male','$department','$section','$year_grade')";

                  if(@!mysql_query($insert)){
                    die('error insert'.mysql_error());


                    }
            }



        }

}

but im having trouble if the array has no value it wont insert in the database.
i made an if statement but i guess its no use.

  • 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-12T06:11:29+00:00Added an answer on June 12, 2026 at 6:11 am

    The problem is here:

    if($arrayfname[$v]!="" && $arraymname[$v]="" &&   $arraylname[$v]=""){
    

    You are using a single = for the second two conditionals. Change them to == or ===.

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

Sidebar

Related Questions

how are you guys? I'm trying to make my PHP script accept many languages,
Hi guys Im trying to make a drop-down list of countries and when the
guys im trying to make a dynamic design for adding students in a class
Hi guys im trying to make my textbox to view names on each item
Hey guys im trying to make a dynamic scrollable list of selectiondata which a
Hey guys I'm trying to make a GUI which can navigate through JTextAreas when
Hello guys look to my code I'm trying to make a program which asks
Hi guys i am trying to create one simple make file and execute in
hey guys, im trying to make a volunteer form, that takes info such as
Guys, this can't be for real I'm trying to make a .NET 2.0 executable

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.