How PHP lets select be selected

Source: Internet
Author: User
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









<{foreach from= $res _grade item=mess}> <{/foreach}>
Grade number Grade Name Grade Status
<{$mess .gradeid}> <{$mess .gradename}>
----How is this part written?



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
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.