我有一个我在wordpress 中编写的php 页面,它应该从数据库中获取一些信息并将其显示到页面上。我正在尝试添加直接从页面更新信息的功能,并且某些东西似乎正在剥离我的第一个表单标签,但不是其他标签。有没有人见过这样的事情,或者可能知道可能发生的事情?
这是PHP
function display_terms_by_brand()
{
global $wpdb;
$sql = "SELECT * FROM ".NINJA_FORMS_TERMS_TEXT;
$terms = $wpdb->get_results($sql, ARRAY_A);
?>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('.edit').click(function(){
jQuery(this).parent().find('.edit').css('display' , 'none')
jQuery(this).parent().find('.save').css('display' , 'block')
jQuery(this).parent().siblings('span[id*=brand_text_]').children('span').toggle();
jQuery(this).parent().siblings('span[id*=brand_text_]').children('textarea').toggle();
});
})
</script>
<div id="termsHeader" style="font-weight:bold; font-size:16px; padding:10px 0; height:30px; min-width:600px;">
<span style="width:10%; text-align:center; float:left; padding:0 30px;">Brand</span>
<span style="width:67%; text-align:center; float:left;">Text</span>
<span style="width:9%; text-align:center; float:right; padding:0 15px;">Edit / Save</span>
</div>
<div style="clear:both;"><!-- --></div>
<hr />
<?php
foreach($terms as $curr_term) {
?>
<div style="width:100%; padding:20px 0; min-width:600px;" class="term">
<span style="width:10%; height:50px; padding:30px; float:left; text-align:center;" id="brand_name_<?php echo $curr_term['text_id'] ?>">
<?php echo $curr_term['brand_name'] ?>
</span>
<span style="width:67%; height:50px; padding:30px 10px; float:left;" id="brand_text_<?php echo $curr_term['text_id'] ?>">
<span> <?php echo stripslashes($curr_term['brand_text']) ?> </span>
<textarea style="display:none; width:100%;"><?php echo stripslashes($curr_term['brand_text']) ?></textarea>
</span>
<span style="width:12%; height:50px; padding:30px 10px; float:right;">
<form action="/wp-admin/admin.php?page=ninja-forms-extend" method="post" name="edit_<?php echo $curr_term['text_id'] ?>" id="edit_<?php echo $curr_term['text_id'] ?>">
<input name="brand_name" type="hidden" value="<?php echo $curr_term['brand_name'] ?>" />
<textarea name="brand_text" style="display:none;">TEST</textarea>
<input class="termsEditButton termsButtons edit" style="width:150px; margin:0 auto; display:block;" name="edit" type="button" value="Edit Optin Statement" />
<input class="termsSaveButton termsButtons save" style="width:150px; margin:0 auto; display:none;" name="save" type="button" value="Save Optin Statement" />
<input class="termsDeleteButton termsButtons delete" style="width:150px; margin:0 auto; display:block;" name="delete" type="button" value="Delete Optin Statement" />
</form>
</span>
</div>
<div style="clear:both;"><!-- --></div>
<?php
}
?>
<hr />
<h2>Add New Terms text</h2>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>?page=ninja-forms-extend" method="post" name="add_new_term_text" id="add_new_term_text">
<label style="float:left;width:50px;clear:left;font-weight:bold">Brand</label><input name="brand_name" type="text" size="38" /> (This will be the shortcode to display the text)<br />
<label style="float:left;width:50px;clear:left;font-weight:bold">Text</label><textarea name="brand_text" cols="35" rows="5"></textarea><br />
<input name="submit" type="submit" value="Add New Terms Text" />
</form>
<?php
return;
}
第一次通过循环的结果html是这样的:
<div style="width:100%; padding:20px 0; min-width:600px;" class="term">
<span style="width:10%; height:50px; padding:30px; float:left; text-align:center;" id="brand_name_1">
caprizehouse </span>
<span style="width:67%; height:50px; padding:30px 10px; float:left;" id="brand_text_1">
<span> I certify that I am a resident of Canada over the age of 18, I agree to the <a href="http://coreg.intela.com/media/ca-prizehouse/privacypolicy.htm" class="fancylink" target="_blank">Privacy Policy</a> and <a href="http://coreg.intela.com/media/ca-prizehouse/terms.htm" class="fancylink" target="_blank">Terms and Conditions</a>, and I would like to receive the Canadian Prize House newsletter. </span>
<textarea style="display:none; width:100%;">I certify that I am a resident of Canada over the age of 18, I agree to the <a href="http://coreg.intela.com/media/ca-prizehouse/privacypolicy.htm" class="fancylink" target="_blank">Privacy Policy</a> and <a href="http://coreg.intela.com/media/ca-prizehouse/terms.htm" class="fancylink" target = "_blank">Terms and Conditions</a>, and I would like to receive the Canadian Prize House newsletter.</textarea>
</span>
<span style="width:12%; height:50px; padding:30px 10px; float:right;">
<input name="brand_name" type="hidden" value="caprizehouse">
<textarea name="brand_text" style="display:none;">TEST</textarea>
<input class="termsEditButton termsButtons edit" style="width:150px; margin:0 auto; display:block;" name="edit" type="button" value="Edit Optin Statement">
<input class="termsSaveButton termsButtons save" style="width:150px; margin:0 auto; display:none;" name="save" type="button" value="Save Optin Statement">
<input class="termsDeleteButton termsButtons delete" style="width:150px; margin:0 auto; display:block;" name="delete" type="button" value="Delete Optin Statement">
</span>
</div>
注意表单标签是如何丢失的。从其他两个通过循环,这是页面的 HTML 输出:
<div style="width:100%; padding:20px 0; min-width:600px;" class="term">
<span style="width:10%; height:50px; padding:30px; float:left; text-align:center;" id="brand_name_2">
canadianprizes </span>
<span style="width:67%; height:50px; padding:30px 10px; float:left;" id="brand_text_2">
<span> I certify that I am a Canadian resident above the age of 18 years and I agree to and accept the <a target="_blank" class="fancylink" href="http://www.canadianprizes.com/media/canadianprizes/terms.jspx"> Terms and Conditions</a>, <a target="_blank" class="fancylink" href="http://www.canadianprizes.com/media/canadianprizes/privacy.jspx">Privacy Policy</a> and <a target="_blank" class="fancylink" href="http://www.canadianprizes.com/media/canadianprizes/prizepolicy.jspx">Competition Rules</a>. I consent to my personal details being provided to selected clients, sponsors and affiliates and to being contacted via email, phone, SMS or mail, as described in the Privacy Policy. </span>
<textarea style="display:none; width:100%;">I certify that I am a Canadian resident above the age of 18 years and I agree to and accept the <a target="_blank" class="fancylink" href="http://www.canadianprizes.com/media/canadianprizes/terms.jspx"> Terms and Conditions</a>, <a target="_blank" class="fancylink" href="http://www.canadianprizes.com/media/canadianprizes/privacy.jspx">Privacy Policy</a> and <a target="_blank" class="fancylink" href="http://www.canadianprizes.com/media/canadianprizes/prizepolicy.jspx">Competition Rules</a>. I consent to my personal details being provided to selected clients, sponsors and affiliates and to being contacted via email, phone, SMS or mail, as described in the Privacy Policy.</textarea>
</span>
<span style="width:12%; height:50px; padding:30px 10px; float:right;">
<form action="/wp-admin/admin.php?page=ninja-forms-extend" method="post" name="edit_2" id="edit_2">
<input name="brand_name" type="hidden" value="canadianprizes">
<textarea name="brand_text" style="display:none;">TEST</textarea>
<input class="termsEditButton termsButtons edit" style="width:150px; margin:0 auto; display:block;" name="edit" type="button" value="Edit Optin Statement">
<input class="termsSaveButton termsButtons save" style="width:150px; margin:0 auto; display:none;" name="save" type="button" value="Save Optin Statement">
<input class="termsDeleteButton termsButtons delete" style="width:150px; margin:0 auto; display:block;" name="delete" type="button" value="Delete Optin Statement">
</form>
</span>
</div>
在那里,您会注意到正确应用了表单标签。