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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:09:13+00:00 2026-06-10T21:09:13+00:00

Hello currently I’m working with this line of code: if( $get_display->level== Nursery){ $lbl=Kinder; }

  • 0

Hello currently I’m working with this line of code:

    if( $get_display->level== "Nursery"){
        $lbl="Kinder";
        }
    else if( $get_display->level== "Kinder"){
        $lbl="Preparatory";
        }
    else if( $get_display->level== "Preparatory"){
        $lbl="Grade 1";
        }
    else if( $get_display->level== "Grade 1"){
        $lbl="Grade 2";
        }
     ******THE else if goes on but still the same*****

So I’m planning to automatically Pick a section depending on the students grade, I am planning to put this code in each of the if statements above. Like this:

    else if( $get_display->level== "Grade 1"){
        $lbl="Grade 2";
                 if($get_display->gpa => "88"){ 
       $result = mysql_query("SELECT * FROM tbl_section where level='$lbl' 
       and section_name="A"");
       $row = mysql_fetch_array($result);
               $sname = $row['section_name'];
               }else if($get_display->gpa => "80"){ 
       $result = mysql_query("SELECT * FROM tbl_section where level='$lbl' 
       and section_name="B"");
       $row = mysql_fetch_array($result);
               $sname = $row['section_name'];
       }else if($get_display->gpa => "75"){ 
       $result = mysql_query("SELECT * FROM tbl_section where level='$lbl' 
       and section_name="C"");
       $row = mysql_fetch_array($result);
               $sname = $row['section_name'];                        
                    }
        }

And $sname would be used here:

    <input type="text"  name="levele" value="<?php echo $sname;?>">

My main problem now is what if section a is full , it should automatically insert to section b right? how should i be able to do that? and should i add a field in my tbl_section to count the student who are in? And if i would tamper my DB how should it look?would appreciate any help.
(pls don’t mention my DB is very compromised, already know that just a simple project but i will implement mysql_real_escape_string() later on, don’t have the knowledge on mysqli yet.)

EDIT: section a and b are just field names in my Database here is what tbl_section looks like.

     section_id (int)
     section_name(vchar)(default names are A,B,C and cannot be changed)
     sy (school year) 
     adviser_id
     level

Sorry first time to show my db here hope this is correct.

  • 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-10T21:09:15+00:00Added an answer on June 10, 2026 at 9:09 pm

    I would just SELECT a section_name that is not full:

    SELECT section_name, COUNT(*) 
    FROM tbl_section 
    WHERE level='$lbl' 
    GROUP BY section_name
    HAVING COUNT(*) < 80 
    LIMIT 1
    

    You also need to stop using mysql_ functions as they are being deprecated and are vulnerable to SQL injection.

    Also, I would rewrite your snippet above to condense code like so:

    elseif( $get_display->level== "Grade 1" ) {
        $lbl="Grade 2";
    
        if( $get_display->gpa => "88" ) {
            $section_name = 'A';
        }
        elseif( $get_display->gpa => "80" ) {
            $section_name = 'B';
        }
        elseif( $get_display->gpa => "75" ) {
            $section_name = 'C';                      
        }
    
        $result = mysql_query("SELECT * FROM tbl_section where level='$lbl' and section_name='$section_name' LIMIT 1");
        $row = mysql_fetch_array($result);
        $sname = $row['section_name'];  
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello currently working with this code $qry_display = SELECT student_id, fname, sex, lname, mname,
Hello I currently have this code checking if a cookie exists, it works all
So I currently have this code: (ns contact-form.core (:gen-class)) (def foo Hello World!) (defn
Hello this is my question: I am currently working on an introductory course on
Currently it outputs the reverse string using this code: string = 'Hello World!' my_reverse
Hello I'm currently on Day 2 of Jeffrey Way's Codeigniter tutorial. In this screencast
Hello everyone I'm currently having 2 issues with the code below: Upon return of
Hello Ruby/Rails/Merb developers! Im currently working on a web project that will have a
Currently I am doing this: I have text that looks like: Hello ${user.name}, this
Hello I currently have this PHP Script <?php if($purchase_dates != FALSE){?> <?php foreach($purchase_dates as

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.