我在使用SartajPHP Select Control时遇到问题。它无法从数据库获取数据。实际上,我在其中编辑或插入新记录的此雇员表格。我使用了面板,标签和表单控件。一切正常,但在选择字段中需要选择员工身份。我试图从数据库中获取员工的当前状态。因此,当尝试渲染临时文件时。它给出了由Select Control生成的SQL查询错误。我不知道该怎么办。这是我的临时文件代码..

<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>


它给了我sql语法错误。

最佳答案

您将错误的参数传递给“选择控制”功能。您需要至少提供表名。

    <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="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>


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

10-05 21:33