How PHP enables Select to be selected
You master, I am a beginner, recently do PHP, the number from the database can not be displayed on the page, please help, very feeling you.
The process is as follows:
A table in MySQL database is School_grade
The contents are as follows:
Gradeid Gradename Gradestate
2012 Level 12 Graduation
2013 Level 12 in school
The following is Smaryt
The 1 model layer is:
Class Manamodel
{
Public Function Showgrade () {
This is for showing grades.
$sqlHelper =new sqlHelper ();
$sql = "SELECT * from School_grade";
$result = $sqlHelper->execute_selectarray ($sql);
$sqlHelper->close_connect ();
return $result;
}
}
2 The control layer is:
Require_once '. /models/manamodle.class.php ';
$dataModel =new Manamodle ();//Instantiate User templates
$smarty->assign ("Res_grade", $dataModel->showgrade ());//used to display grade
$smarty->display ("manager.html");
?>
3 View (templates) layer:
Grade setting
Grade number |
Grade Name |
Grade Status |
<{foreach from= $res _grade item=mess}>
<{$mess .gradeid}> |
<{$mess .gradename}> |
----How is this part written?
|
<{/foreach}>
I would like to show in the table, there is a select, level 12 for graduation, that is shown as "graduation", 13 people in school, select "in school", while the two internal states are still there, please write the code, using JavaScript can also, please help outside busy, I will be very grateful.
------to solve the idea----------------------
> Graduation
> In school
------to solve the idea----------------------
I don't know how to use Smaryt's label, try it first.
------to solve the idea----------------------
On the option that needs to be selected, add
For example
> MaleWoman
------to solve the idea----------------------
reference:
Quote: reference:
> graduated
> in school
This method I tried, can not be based on the value of $mess.gradestate to determine which value is selected, the execution result is ' graduation ',
but also very grateful.
Why the value of two option is {$mess. Gradestate}, there is a problem here, in addition you said that can not be based on $ The value of Mess.gradestate to determine which value is selected, which is odd, so you can test
Echo $mess. gradestate;
Var_dump ($mess. gradestate== ' in school ');
To see what the output is.
------Solutions----------------------
Filling Option,smarty has a special method Http://www.111cn.net/phper/122/smarty_html_ options_select.htm