Wordpress没有执行mysql_query()(Wordpress not executing mysql_query())
我已将旧版Wordpress(3.0.1)更新为4.4.2。 一切都有效,除了一个插件,它有这种风格的所有查询。 我使用自定义页面来测试一个简单的查询,并可以验证查询没有返回任何内容:
$query = "SELECT code FROM wp_kk_video WHERE id = '0'"; $result = mysql_query ($query);
然后我用以下内容替换了该查询:
$query = $wpdb->get_row( "SELECT code FROM wp_kk_video WHERE id = '0'" ); $result = $query->code;
它运作得很好。
那么为什么Wordpress会停止执行旧类型的
mysql_query
查询呢?I have updated an old version of Wordpress (3.0.1) to 4.4.2. Everything works, except for one plugin, which has all queries in this style. I have used a custom page to test a simple query and can verify that the query returns nothing:
$query = "SELECT code FROM wp_kk_video WHERE id = '0'"; $result = mysql_query ($query);
Then I replaced that query with the following:
$query = $wpdb->get_row( "SELECT code FROM wp_kk_video WHERE id = '0'" ); $result = $query->code;
And it worked perfectly.
So why has Wordpress stopped executing the old type of
mysql_query
queries?
原文:https://stackoverflow.com/questions/35830554
最满意答案
我的代码已经在我的项目中的某个地方已经存在,根据您的需要进行了一些调整。
Jquery部分
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script> $(document).ready(function(){ $(".remove_tr").click(function(){ var tr_id = $(this).parent().attr("id"); var flag = "N"; var row_cnt = 0; $("#dummy_table tr").each(function(){ if( flag == "Y" ){ $(this).attr("id", "row_"+ row_cnt); $(this).children("td:first-child").html("row_"+ row_cnt); $(this).attr("id", "row_"+ row_cnt); row_cnt++; } if( flag =="N" && $(this).attr("id") == tr_id){ var rowArr = $(this).attr("id").split("_"); row_cnt = rowArr[1]; $(this).remove(); flag= "Y"; } }) }); }); </script>
HTML部分
<table id="dummy_table"> <?php for($i = 0; $i < 10; $i++){ ?> <tr id="row_<?php echo $i; ?>"> <td>row_<?php echo $i; ?></td> <td class="remove_tr">remove</td> </tr> <?php } ?> </table>
请让我知道这对你有没有用
I'd this code already with me somewhere in my project, tweaked little but as per your need.
Jquery part
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script> $(document).ready(function(){ $(".remove_tr").click(function(){ var tr_id = $(this).parent().attr("id"); var flag = "N"; var row_cnt = 0; $("#dummy_table tr").each(function(){ if( flag == "Y" ){ $(this).attr("id", "row_"+ row_cnt); $(this).children("td:first-child").html("row_"+ row_cnt); $(this).attr("id", "row_"+ row_cnt); row_cnt++; } if( flag =="N" && $(this).attr("id") == tr_id){ var rowArr = $(this).attr("id").split("_"); row_cnt = rowArr[1]; $(this).remove(); flag= "Y"; } }) }); }); </script>
HTML part
<table id="dummy_table"> <?php for($i = 0; $i < 10; $i++){ ?> <tr id="row_<?php echo $i; ?>"> <td>row_<?php echo $i; ?></td> <td class="remove_tr">remove</td> </tr> <?php } ?> </table>
Let me know if it works for you
相关问答
更多-
for(var key in data){ dataTable += '
' + data[key].id + ' ' + data[key].name + ' ' + data[key].address + ' 使用Jquery按顺序删除和更新动态创建的表行ID(Delete and Update dynamically created Table row ID's serially using Jquery)[2021-09-19]
我的代码已经在我的项目中的某个地方已经存在,根据您的需要进行了一些调整。 Jquery部分