使用PHP更新WordPress数据库。

huangapple go评论69阅读模式
英文:

update wordpress database with php

问题

I am trying to update my WordPress database when the button "btn-upddb" is clicked.
我的目标是在单击"btn-upddb"按钮时更新我的WordPress数据库。

My PHP code:
我的PHP代码:

if(isset($_POST['btn-upddb'])){
    global $wpdb;
    $wpdb->update(
        $wp_uwp_usermeta,
        array( 
            'user_volume' => '1500'
       ),
       array(
        'user_id' => '1'
    )
);
}

The HTML code is:
HTML代码如下:

<form method="post">
<input name="btn-upddb" type="submit" value="update database" />
</form>

I tried the PHP code and the HTML code at the top, and I am expecting to update the table wp_uwp_usermeta.
我尝试了顶部的PHP代码和HTML代码,我希望更新wp_uwp_usermeta表格。

英文:

i am trying to update my wordpress database when button "btn-upddb" is clicked.
my php code:

if(isset($_POST[&#39;btn-upddb&#39;])){
    global $wpdb;
    $wpdb-&gt;update(
        $wp_uwp_usermeta,
        array( 
            &#39;user_volume&#39; =&gt; &#39;1500&#39;
       ),
       array(
        &#39;user_id&#39; =&gt; &#39;1&#39;
    )
);
}

the html code is:

&lt;form method=&quot;post&quot;&gt;
&lt;input name=&quot;btn-upddb&quot; type=&quot;submit&quot; value=&quot;update database&quot; /&gt;
&lt;/form&gt;

i tried the php code and the html code in the top and i am expecting to update the table wp_uwp_usermeta

答案1

得分: 1

你的表名不正确,可以像这样使用表名:

$table_name = $wpdb->prefix . 'wp_usermeta';

然后在你的代码中使用正确的表名。

以下命令显示你的动态前缀:

$wpdb->prefix
英文:

You are not using a correct name for your table name, you can use something like this for your table name :

$table_name = $wpdb-&gt;prefix . &#39;wp_usermeta&#39;;

and then you can use the correct table name in your codes.

This below command shows your dynamic prefix :

$wpdb-&gt;prefix

huangapple
  • 本文由 发表于 2023年7月6日 20:59:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76629116.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定