gpt4 book ai didi

php - WordPress:获取数据并排序

转载 作者:行者123 更新时间:2023-11-30 00:46:03 24 4
gpt4 key购买 nike

表名称:wp_ninja_forms_subs

Data in table

id (int) = 1
user_id (int) = 1
form_id (int) = 1
data (longtext) = `a:12:{i:0;a:2:{s:8:"field_id";i:16;s:10:"user_value";s:4:"test";}i:1;a:2:{s:8:"field_id";i:6;s:10:"user_value";s:4:"test";}i:2;a:2:{s:8:"field_id";i:15;s:10:"user_value";s:14:"(808) 080-8080";}i:3;a:2:{s:8:"field_id";i:8;s:10:"user_value";s:14:"asdf@gmail.com";}i:4;a:2:{s:8:"field_id";i:10;s:10:"user_value";s:6:"sfasdf";}i:5;a:2:{s:8:"field_id";i:3;s:10:"user_value";s:12:"ksfasdlkfadf";}i:6;a:2:{s:8:"field_id";i:11;s:10:"user_value";s:0:"";}i:7;a:2:{s:8:"field_id";i:12;s:10:"user_value";s:5:"Admin";}i:8;a:2:{s:8:"field_id";i:13;s:10:"user_value";s:8:"Forgtown";}i:9;a:2:{s:8:"field_id";i:14;s:10:"user_value";s:8:"sadfasdf";}i:10;a:2:{s:8:"field_id";i:4;s:10:"user_value";s:1:"7";}i:11;a:2:{s:8:"field_id";i:5;s:10:"user_value";s:0:"";}}`

date_updated = 2014-01-25 11:02:01
<小时/>

查询

$subs_results = $wpdb->get_results("SELECT * FROM wp_ninja_forms_subs WHERE form_id = 1 ORDER BY date_updated DESC")

如何打印“数据”字段值?

我还想按“数据(电话)”对数据进行排序。这可能吗?

最佳答案

以下代码会将此字符串转换为数组并打印“data”字段值...

foreach ($subs_results as $sub)
{
$data = unserialize($sub->data);
echo "<pre>";
print_r($data);
echo "</pre>";
}

关于php - WordPress:获取数据并排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21355237/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com