admin管理员组文章数量:1326314
Notice: wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder. Please see Debugging in WordPress for more information. (This message was added in version 3.9.0.) in /home/****/public_html/wp-includes/functions.php on line 5167
Notice: Undefined offset: 0 in /home/****/public_html/wp-includes/wp-db.php on line 1310
function branch_students(){
$content='';
$content.='<div class="container">';
$content.='<h1 align=center class="fofa">Enter Branch</h1>';
$content.='<form method="post" >';
$content.='<div class="b2">';
$content.='<input type="text" name="branch" id="branch" class="box" placeholder="Enter Branch" required */></div>';
$content.='<br>';
$content.='<div>';
$content.='<button type="submit" name="save" class="btn_Register" value="save">Save</button>';
$content.='</div>';
$content.='</form>';
$content.='</div>';
return $content;
}
this is my first form in this form i creates branches. now i want database of this branch form should be showed in the following table as selection options.
function arsh_forms(){
$content .='<div class="col-sm-6">';
$content .='<label class="fofa" style=" font: italic bold 12px/30px Georgia, serif; font-size:26px;color:black;">Select Branch</label>';
$content .='<select name="selectbranch"id="selectbranch" class="form-control"style=" font: italic bold 12px/30px Georgia, serif; font-size:20px;"placeholder="selectbranch"required/>';
$content .='<option value="0" >select branch</option>';
global $wpdb;
$table_name=$wpdb->prefix.'arsh_branch';
$select_branch = $wpdb->get_results($wpdb->prepare("SELECT * FROM $table_name"));
if(count($select_branch) > 0){
foreach ($select_branch as $key=>$value){
$content .='<option value="<?php echo $value->branches; ?>">
<?php echo ucwords($value->branches);?></option>';
}
}
$content .='</select>';
$content.='<div class="col-sm-6">';
$content .='<button type="submit" name="submit" value="Register" style=" width:30%;height:35px;background-color:black;color:white;float:right; margin-top:40px;"
class="bt">Register</button>';
$content .='</div>';
}
i think now it is understandable.plz if anybody can help me?
Notice: wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder. Please see Debugging in WordPress for more information. (This message was added in version 3.9.0.) in /home/****/public_html/wp-includes/functions.php on line 5167
Notice: Undefined offset: 0 in /home/****/public_html/wp-includes/wp-db.php on line 1310
function branch_students(){
$content='';
$content.='<div class="container">';
$content.='<h1 align=center class="fofa">Enter Branch</h1>';
$content.='<form method="post" >';
$content.='<div class="b2">';
$content.='<input type="text" name="branch" id="branch" class="box" placeholder="Enter Branch" required */></div>';
$content.='<br>';
$content.='<div>';
$content.='<button type="submit" name="save" class="btn_Register" value="save">Save</button>';
$content.='</div>';
$content.='</form>';
$content.='</div>';
return $content;
}
this is my first form in this form i creates branches. now i want database of this branch form should be showed in the following table as selection options.
function arsh_forms(){
$content .='<div class="col-sm-6">';
$content .='<label class="fofa" style=" font: italic bold 12px/30px Georgia, serif; font-size:26px;color:black;">Select Branch</label>';
$content .='<select name="selectbranch"id="selectbranch" class="form-control"style=" font: italic bold 12px/30px Georgia, serif; font-size:20px;"placeholder="selectbranch"required/>';
$content .='<option value="0" >select branch</option>';
global $wpdb;
$table_name=$wpdb->prefix.'arsh_branch';
$select_branch = $wpdb->get_results($wpdb->prepare("SELECT * FROM $table_name"));
if(count($select_branch) > 0){
foreach ($select_branch as $key=>$value){
$content .='<option value="<?php echo $value->branches; ?>">
<?php echo ucwords($value->branches);?></option>';
}
}
$content .='</select>';
$content.='<div class="col-sm-6">';
$content .='<button type="submit" name="submit" value="Register" style=" width:30%;height:35px;background-color:black;color:white;float:right; margin-top:40px;"
class="bt">Register</button>';
$content .='</div>';
}
i think now it is understandable.plz if anybody can help me?
Share Improve this question edited Aug 7, 2020 at 9:42 Arshpreet Venveru asked Aug 7, 2020 at 6:16 Arshpreet VenveruArshpreet Venveru 94 bronze badges 4- What's your question? – Jacob Peattie Commented Aug 7, 2020 at 6:43
- i want to add select option in my form and i added items in other form but it should showed on this form as selecting items. – Arshpreet Venveru Commented Aug 7, 2020 at 6:47
- Nothing included in the question is remotely useful in understanding your issue (what's the other form? how is it saved?), and I can't see what it has to do with WordPress either. – Jacob Peattie Commented Aug 7, 2020 at 6:58
- Although I have given an answer on what I believe is incorrect in your code. I do agree with Jacob, that, the question should be clearly written here with more details to allow people to answer. You can still edit the question and update it so that if someone else stumbles here, they can get a better understanding of it as well – shivaramanaiyer Commented Aug 7, 2020 at 7:29
2 Answers
Reset to default 0In the following line: $select_branch = $wpdb->get_results($wpdb->prepare("SELECT * FROM $table_name"));
, you are using $wpdb->prepare
incorrectly. wpdb::prepare
needs two arguments, first one is a Query string with sprintf like placeholders and second an array of the values to to substitute the placeholders. More details here. And that is the error you are getting as posted on top of your question.
yeah i got answer
$content .='<select name="selectbranch"id="selectbranch" class="form-control"style=" font: italic bold 12px/30px Georgia, serif; font-size:20px;"placeholder="selectbranch"required/>';
$content .='<option >select branch</option>';
global $wpdb;
$table_name=$wpdb->prefix.'arsh_branch';
$select_branch = $wpdb->get_results("SELECT * FROM $table_name");
if(count($select_branch) > 0){
foreach ($select_branch as $key=>$value){
$content .='<option value= "'.$value->branches.'">'
.$value->branches.'</option>';
}
}
$content .='</select>';
本文标签: pluginsselecting options from another form
版权声明:本文标题:plugins - selecting options from another form 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742203956a2432468.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论