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.
I would just
SELECTasection_namethat is not full: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: