简体   繁体   English

如何在SartajPHP Framework中将MySQL表中的数据填充到Select Input Field Control中

[英]How to fill data from MySQL table into Select Input Field Control in SartajPHP Framework

I have problem with SartajPHP Select Control. 我在使用SartajPHP Select Control时遇到问题。 It couldn't get data from database. 它无法从数据库获取数据。 Actually this employee form in which i edit or insert new records. 实际上,我在其中编辑或插入新记录的此雇员表格。 I used panel,tab and form controls. 我使用了面板,标签和表单控件。 all is working well but in select field where i need to select employee status. 一切运行良好,但在选择字段中需要选择员工身份。 i am trying to get current status of employee from database. 我正在尝试从数据库中获取员工的当前状态。 so when try to render temp file. 因此,当尝试渲染临时文件时。 it gives SQL query error which generated by Select Control. 它给出了由Select Control生成的SQL查询错误。 I don't know what to do here. 我不知道该怎么办。 here is my code of temp file .. 这是我的临时文件代码..

<panel id="pnlEdit" funsetLabel="Edit Employee" runat="server" path="controls/bootstrap3/EditPanel.php">
<div id="tab1" runat="server" path="controls/bootstrap3/Tabs.php" >
<tabhead runas="ul" class="nav nav-tabs">
    <li class=""><a data-toggle="tab" href="#sectionA">GENERAL</a></li>
    <li class=""><a data-toggle="tab" href="#sectionB">DEPARTMENTS</a></li>
    <li class=""><a data-toggle="tab" href="#sectionC">WORK LIST</a></li>
</tabhead>

<tabcontent runas="div" class="tab-content">
    <sectionA runas="div" id="sectionA" class="tab-pane fade">

    <form id="form2" class="form-horizontal form-striped" runat="server" funsetAJAX="" action="##{ getAppPath('user'); }#">
            <label id="lbl1" path="controls/bootstrap3/HLabel.php" fupsetLabel="First Name,|txtfname" runat="server" funsetSize="col-md-4,|col-md-8">
            <input id="txtfname" runat="server" type="text" dfield="txtfname" class="form-control" funsetForm="form2" funsetMsgName="First Name" funsetMaxLen="40" funsetRequired=""  />
             </label>
            <label id="lbl1" fupsetLabel="Last Name,|txtlname" runat="server" >
            <input id="txtlname" runat="server" type="text" dfield="txtlname" class="form-control" funsetForm="form2" funsetMsgName="Last Name" funsetMaxLen="40"  funsetRequired=""  />
             </label>
            <label id="lbl1" fupsetLabel="Email,|emlemail" runat="server" >
            <input id="emlemail" runat="server" type="text" dfield="emlemail" class="form-control" funsetForm="form2" funsetMsgName="Email" funsetMaxLen="100" funsetEmail=""  />
             </label>
            <label id="lbl1" fupsetLabel="Pin,|numpin" runat="server" >
            <input id="numpin" runat="server" type="text" dfield="numpin" class="form-control" funsetForm="form2" funsetMsgName="Pin" funsetMaxLen="11" funsetNumeric=""  />
             </label>
            <label id="lbl1" fupsetLabel="Current Status,|sltcurrent_status" runat="server" >
            <select id="sltcurrent_status" runat="server" dfield="sltcurrent_status" class="form-control" funsetForm="form2" funsetMsgName="Current Status" funsetOptionsFromTable="astatus,atype,where id='##{$page->evtp}#'" ></select>
             </label>
            <label id="lbl1" fupsetLabel="Allow Change Team,|chkCanchangeteams" runat="server" >
            <input id="chkCanchangeteams"  type="checkbox" runat="server" dfield="chkCanchangeteams" class="form-control" funsetForm="form2" funsetMsgName="Allow Change Team" />
             </label>
    <div class="align-center"><br /><input type="submit" value="Save" class="btn btn-primary btn-small" />
    <input type="reset" value="New" class="btn btn-primary btn-small" onclick="setFormAsNew('form2');" />
    <input id="btnDel" runat="server" type="button" value="Delete" onclick="confirmDel_showall('##{ getEventPath('delete',$page->evtp,'user','','',true); }#');" class="btn btn-danger btn-small" />
    </div>
</form>
</sectionA>

   <sectionB runas="div" id="sectionB" class="tab-pane fade">
........
.....
</sectionB>
</tabcontent>
</div>

It gives me sql syntax error. 它给了我sql语法错误。

You passed wrong parameter to Select Control function. 您将错误的参数传递给“选择控制”功能。 You need to give at least table name.. 您至少需要提供表名。

    <label id="lbl1" fupsetLabel="Current Status,|sltcurrent_status" runat="server" >
    <select id="sltcurrent_status" runat="server" dfield="sltcurrent_status" class="form-control" funsetForm="form2" funsetMsgName="Current Status" funsetOptionsFromTable="astatus,atype,where id='##{$page->evtp}#'" ></select>
     </label>

Changed with this code .. 更改此代码..

    <label id="lbl1" fupsetLabel="Current Status,|sltcurrent_status" runat="server" >
    <select id="sltcurrent_status" runat="server" dfield="sltcurrent_status" class="form-control" funsetForm="form2" funsetMsgName="Current Status" funsetOptionsFromTable="astatus,|atype,|mytable,|where id='##{$page->evtp}#'" ></select>
     </label>

For more info check SartajPHP Framework API http://www.sartajphp.com/api/classes/Select.html#method_setOptionsFromTable 有关更多信息,请检查SartajPHP Framework API http://www.sartajphp.com/api/classes/Select.html#method_setOptionsFromTable

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM