Hello having a bit of problem retrieving a value so i might use it.
This is is where i should get my value.
<input type="text" class="typed" readonly="readonly" name="levele"
value="<?php
if($get_display->level== "Grade 2") {
echo "Grade 4"; $lbl="Grade 4";
}?>">
For a simple test i will use the value Grade 4 because i know what the outcome I’m suppose to have. This is the code that i want to retrieve the value of “levele” so it may perform a SQL statement. For example i have 5 sections that are for grade 4 so i was thinking on using this sql statement.
<select name="section_id">
<option>SECTIONS</option>
<?php
$result = mysql_query("SELECT * FROM tbl_section where level='".$_GET['levele']."'");
while($row = mysql_fetch_array($result))
{
echo '<option value='.$row['section_id'].'>' .$row['section_name']. '</option>';
}
?>
</select>
So far i am unable to retrieve “levele” so it may be used it the sql, also tried $_POST and $_request but nothing and i check if levele does have the value Grade 4 and it does also in my database. Would appreciate any help on this. Because after i have retrieve the 5 sections I will try to automatically select one section where for example if the student has a grade of 90 the section should be “A” I’m going to do it with if else. so i would appreciate any help to solve these problems.
I see three main problems here that I think you should address:
Firstly, in your code at the top:
Your code will only echo and set a value if
$get_display->levelis equal to 2. Did you mean to add in an else statement as well in case the value is something other thanGrade 2perhaps?Secondly, your form section of code seems to be missing quotes around the values:
I think you meant to use this:
Lastly, your code is very vulnerable to injection attacks. You really should look at moving to PDO and prepared statements when dealing with form data.
Edit: This is just an afterthought, but I can’t see anywhere that you set
$resultto a valid connection, but I assume that this is somewhere else in your code.