RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-254416

theblackpost's questions

Martin Hope
theblackpost
Asked: 2020-04-26 16:26:29 +0000 UTC

OpenCart 检查页面是否为产品

  • 0

告诉我,有什么方法/方法可以检查当前页面是否是 header.tpl、footer.tpl 中的产品?例如:if (is_product) { // do something }

opencart
  • 1 个回答
  • 10 Views
Martin Hope
theblackpost
Asked: 2020-02-07 19:49:37 +0000 UTC

Ajax如何在select中拉取值?

  • 0

有一个数组:

array (size=5)
  1821175 => 
    array
      'id' => int 1821175
      'name' => string 'Name'
      'statuses' => 
        array
          28235989 => 
            array
              'id' => int 28235989
              'name' => string 'status 1'
              'color' => string '#c1c1c1'
          28235992 => 
            array
              'id' => int 28235992
              'name' => string 'status 2'
              'color' => string '#c1c1c1'
   1931089 => 
    array
      'id' => int 1931089
      'name' => string 'Name 2'
      'statuses' => 
        array
          28235989 => 
            array
              'id' => int 28235989
              'name' => string 'status 3'
              'color' => string '#c1c1c1'
          28235992 => 
            array
              'id' => int 28235992
              'name' => string 'status 4'
              'color' => string '#99ccff'

我用它的 ID 获取每个 Name 的值,如下所示:

<select class="form-control" id="Pipelineselect" name="Pipelineselect">
    <?php
    foreach ($PipeLines as $PipeLine) {
      echo "<option value=".$PipeLine['id'].">".$PipeLine['name']."</option>";
      }
    ?>
</select>

接下来,您需要显示另一个<select></select>,在其中您需要$PipeLine['statuses']为每个选项插入适当的值$PipeLine:也就是说,最终第二个选择中的结果将由ajax加载,它应该看起来像这个:

图片

帮助如何实现这个?

php
  • 2 个回答
  • 10 Views
Martin Hope
theblackpost
Asked: 2020-12-04 19:45:59 +0000 UTC

关于重复键 Mysqli 错误

  • 0
$query = "INSERT INTO actual_amo_columns 
(pipeline_name, status_id, status_name) 
VALUES ('$pipelinename', '$statusid', '$statusname')
ON DUBLICATE KEY UPDATE 
`pipeline_name` = VALUES('$pipelinename'),
`status_id` = VALUES('$statusid'), 
`status_name` = VALUES('$statusname')";

$query_result = mysqli_query($dbcnx,$query) or die(mysqli_error($dbcnx));

我不明白他为什么不喜欢它?

pipeline_name在第 2 行的 'DUBLICATE KEY UPDATE = VALUES('PIPELINE1'), status_id= VAL'附近使用正确的语法

也许值不能为空?那么如何更改请求呢?

如果我做ON DUBLICATE KEY UPDATEpipeline_name = '$pipelinename',那么记录是重复的

php
  • 1 个回答
  • 10 Views
Martin Hope
theblackpost
Asked: 2020-10-01 20:52:41 +0000 UTC

简化 PHP 代码

  • 1

我怎样才能简化这段代码。太多的重复。

$ca0 = round((count_active($dbcnx,0)/$total)*100);
$ca1 = round((count_active($dbcnx,1)/$total)*100);
$ca2 = round((count_active($dbcnx,2)/$total)*100);
$ca3 = round((count_active($dbcnx,3)/$total)*100);
$ca4 = round((count_active($dbcnx,4)/$total)*100);
$ca5 = round((count_active($dbcnx,5)/$total)*100);
$ca6 = round((count_active($dbcnx,6)/$total)*100);
$ca99 = round((count_active($dbcnx,99)/$total)*100);
php
  • 2 个回答
  • 10 Views
Martin Hope
theblackpost
Asked: 2020-09-26 19:07:05 +0000 UTC

MODX REVO 如何从不存在的页面中删除 /404 重定向?

  • 0

现在打开site.com/sdfsdfsdf重定向到 site.com/404/ 并显示 error_page。如何删除此重定向并保留 URL 相同 ( /sdfsdfsdf ) 但仍显示error_page模板。

我在 .htaccess 中没有找到任何规则:

RewriteEngine On
RewriteBase /

# http -> https
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{REQUEST_URI} !^/robots.txt$
RewriteCond %{REQUEST_URI} !^/r.php
RewriteRule .* https://domain.ru%{REQUEST_URI} [R=301,L]

# Rewrite www.domain.com -> domain.com -- used with SEO Strict URLs plugin
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^domain\.ru [NC]
RewriteRule (.*) https://domain.ru/$1 [R=301,L]

RewriteCond %{REQUEST_URI} ^/robots.txt$
RewriteRule ^(.*)$ r.php [L,QSA]

# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

在站点的系统设置中指定了正确的资源 ID error_page

php
  • 1 个回答
  • 10 Views
Martin Hope
theblackpost
Asked: 2020-09-24 18:37:58 +0000 UTC

重新创建数组。前锋

  • 0

有什么出乎意料的。。

我有一个多维数组:

var_export($arrays):

array (
    'items' => 
    array (
      0 => 
      array (
        'id' => 5182729,
        'custom_fields' => 
        array (
          0 => 
          array (
            'id' => 175255,
            'values' => 
            array (
              0 => 
              array (
                'value' => '+7 (912) 345-67-89',
              ),
            ),
          ),
      ),
    ),
  ),
)

我需要重新组装成一个更简单的数组,例如:

array(500){
    array(2){
        ['id'] => int(5182729)
        ['phone'] => string(18) "+7 (912) 345-67-89"
    }
}

我做循环:(我知道没有这么多的foreach是可能的,我找到我需要的东西要快得多)

$arrays(); //старый массив
$new_array = array(); //новый массив
foreach ($arrays as $array) {
   foreach ($array as $item) {
       foreach ($item as $i){
           $lead_id = $value['id'];
           $user_phone = $value['custom_fields'][0]['values'][0]['value'];
           $new_array['user']['phone']=preg_replace("/[^0-9]/", "", $user_phone);
           $new_array['user']['lead_id']= $lead_id;
       }
   }
}

仅通过 1 次即可获得结果:

array(1) {
  ["user"]=>
  array(2) {
    ["phone"]=>
    string(11) "79123456789"
    ["lead_id"]=>
    int(5182729)
  }
}

如何正常填充新数组?

php
  • 2 个回答
  • 10 Views
Martin Hope
theblackpost
Asked: 2020-09-06 18:21:59 +0000 UTC

查询错误 (1054):“字段列表”中的未知列“g.RomNo”

  • 0
SELECT DISTINCT `g.RomNo`
FROM GuestInfo AS g
INNER JOIN RoomInfo AS r 
ON r.RomNo = g.RomNo
WHERE  r.Type != '4'
AND g.goTime >= '2019-09-01 00:00:00' AND  g.ComeTime <= '2019-09-01 00:00:00'

查询错误 (1054):“字段列表”中的未知列“g.RomNo”

但是两个表都有RomNo。并使用 SELECT * 显示所有内容

mysql
  • 1 个回答
  • 10 Views
Martin Hope
theblackpost
Asked: 2020-09-05 17:27:51 +0000 UTC

将时差转换为 PHP 小时

  • 0
$cometime = '2019-09-03 23:40:13';
$gotime = '2019-09-04 12:00:00';

如何以(int)小时计算差异 $gotime - $cometime?

php
  • 1 个回答
  • 10 Views
Martin Hope
theblackpost
Asked: 2020-07-21 21:43:02 +0000 UTC

从数组中获取键的值,只有前一个键

  • 0

有一个数组:


[Array] => Array (
    [linked_leads_id] => Array
        (
            [8814131] => Array
                (
                    [ID] => 8814131
                )

        )
)

数组在不断变化,但我们确切地知道 的位置[Array][linked_leads_id]。

如何获取密钥的名称[Array][linked_leads_id][8814131](数字本身是 8814131)知道它永远是第一个之后linked_leads_id?

还是得到一个不断变化的[Array][linked_leads_id][8814131][ID]给定?8814131

php
  • 1 个回答
  • 10 Views
Martin Hope
theblackpost
Asked: 2020-04-04 01:39:49 +0000 UTC

保持数组中随机出现的值的计数

  • 0

有一个数组: $array = array('a','b','c','d','e');

使用array_rand从数组中获取随机元素

$rndvalue = $array[array_rand($array)];

如何创建一个循环来显示数组中的哪些随机元素被显示了 10 次。不多。所以结果应该是这样的:

b - 10 
a - 5 
c - 7 
d - 8 
e - 1

这里 - b值的 10 倍随机掉出,循环在那里结束。

php
  • 3 个回答
  • 10 Views
Martin Hope
theblackpost
Asked: 2020-03-07 00:46:55 +0000 UTC

有规律的数字。删除空格和破折号后[关闭]

  • 0
关闭 这个问题是题外话。目前不接受回复。

仅当您在提出问题之前尝试自己解决问题时,才允许将学习问题作为问题。请编辑问题并指出究竟是什么导致您难以解决问题。例如,请提供您在尝试解决问题时编写的代码

3年前关闭。

改进问题

有一个字符串包含数字,-,它们之间的空格,请参阅: $string = 50 — 55 см

数字可能会有所不同。

如何删除所有内容并仅保留最后一个数字:55。没有字母,没有空格和破折号?

尝试使用preg_replace('/см/','',$string);,但我只会删除см

php
  • 4 个回答
  • 10 Views
Martin Hope
theblackpost
Asked: 2020-02-08 16:26:21 +0000 UTC

切片功能不适用于 document.querySelector。错误 .slice 不是函数

  • 3

有什么东西弄糊涂了。这是为什么?怎么修?

var longtext = document.querySelector('.excerpt>p:nth-child(2)');// <p>long long text</p>
var cuttext = longtext.slice(0, 40); // Uncaught TypeError: longtext.slice is not a function
if (cuttext.length < longtext) {
    cuttext += "...";
}
javascript
  • 2 个回答
  • 10 Views
Martin Hope
theblackpost
Asked: 2020-01-22 05:57:40 +0000 UTC

在 <form> 中发送 <option> 标记的内容

  • 1

有一个表格:

<form action="#" method="post">
    <input name="phone" type="text" placeholder="enter phone number"><br>
    <select name="URL">
    <? echo '<option value="'.$url.'">'.$section_name.'</option>';
    </select>
    <input type="submit" name="submit" value="Send 2 site" />
 </form>

有一个处理程序:

if(isset($_POST['submit'])){
    $page = $_POST['URL'];
    $phone = $_POST['phone'];
}

如何将 $section_name 值传递给处理程序?它是不同的,不能等于 $url 。$url 值也不能被条件改变。

php
  • 1 个回答
  • 10 Views
Martin Hope
theblackpost
Asked: 2020-12-29 16:09:21 +0000 UTC

bash 没有在 crontab 中运行

  • 0

有这样一个用于创建 mysql 备份的 bash 脚本:

#!/bin/bash
cd /var/www/html/backup/sql-backup
rm site-3.sql
mv site-2.sql site-3.sql
mv site-1.sql site-2.sql
/bin/mv site-0.sql site-1.sql
mysqldump -u USER -p PASSWORD DBNAME > /var/www/html/backup/sql-backup/site-0.sql

我在特定时间由 Debian 上的 crontab 运行:

00 11 * * * root sh /root/mysql-backup.sh

该脚本会在其中创建一个新文件,/var/www/html/backup/sql-backup/site-0.sql但会忽略命令rm和mv. 然后创建一个具有相同名称的文件,但它不工作。但是当您从控制台运行脚本时,一切正常。

linux
  • 1 个回答
  • 10 Views
Martin Hope
theblackpost
Asked: 2020-12-28 14:25:25 +0000 UTC

无法加载证书 .pem

  • 0

实际上,这是错误:

/ssl openssl x509 -inform der -in site_ru.crt -out site_ru.pem
unable to load certificate
140451851716160:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:../crypto/asn1/tasn_dec.c:1130:
140451851716160:error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error:../crypto/asn1/tasn_dec.c:290:Type=X509

开头和结尾都没有多余的字符:

/ssl xxd -l 10 site_ru.crt
00000000: 2d2d 2d2d 2d42 4547 494e                 -----BEGIN 
debian
  • 1 个回答
  • 10 Views
Martin Hope
theblackpost
Asked: 2020-11-20 17:33:39 +0000 UTC

在背景中裁剪图像:url

  • 0
body {
    background: url(./img/body_alt.jpg) top center no-repeat fixed;
    }

图片:1920x1080 像素。在里面<body> ,当然还有内部元素。如何将图像裁剪为 290px 高度?

html
  • 1 个回答
  • 10 Views
Martin Hope
theblackpost
Asked: 2020-10-15 21:50:08 +0000 UTC

MYSQL:表单查询唯一的product_id

  • 0

告诉我如何在 Adminer.php 中正确形成请求。

有一个带有跟踪的数据库表。结构体:

Column  Type    Comment

id  int(11) Auto Increment   
product_id  int(11)  
sku_id  int(11) NULL     
feature_id  int(11)  
feature_value_id    int(11)

例子:

id  product_id  sku_id  feature_id  feature_value_id

401330  1049672 89719   1397    23078
401329  1049672 89719   1394    24321
401328  1049672 NULL    1394    24320
401289  1049667 NULL    1394    24312
401288  1049667 89707   1397    23078
401287  1049667 89707   1394    24312

有必要为所有非重复的 product_id 添加一个 feature_id = 2789 和 feature_value_id = 30654 的新条目

mysql
  • 1 个回答
  • 10 Views
Martin Hope
theblackpost
Asked: 2020-10-12 19:28:31 +0000 UTC

向下移动块 CSS

  • 0

告诉我如何在.rmenu之后移动块<P> .text_block:

HTML:

<div class="content">
    <div class="rmenu"></div>
    <div class="text_block"></div>
    <p>some text</p>
</div>

CSS:

.rmenu {
    position: absolute;
    left: 990px;
    top: -2px;
}
.text_block {
    width: 100%!important;
}

也就是说,在 css 上,确保块.rmenu在标记之后视觉上出现<p>

html
  • 1 个回答
  • 10 Views
Martin Hope
theblackpost
Asked: 2020-10-01 16:19:54 +0000 UTC

WP 更改查询以显示过去 30 天的帖子

  • 1

当前请求:

$popular_posts = get_posts("cat=-104&orderby=comment_count");

必须在最近 30 天内撤回。请求中要更改什么?我了解需要添加&的内容,并且可以通过某个日期(例如,本月退出): $popular_posts = get_posts('cat=-104&orderby=comment_count&year=' . $year . '&monthnum=' . $month); 之前已表明:

$month = date('m');
$year = date('Y');

但是如何处理查询中的天数呢?因此输出是 get_posts 中过去 30 天的输出。也就是如何通过一个参数来传递date_query

php
  • 2 个回答
  • 10 Views
Martin Hope
theblackpost
Asked: 2020-08-31 16:02:56 +0000 UTC

.htaccess 如果没有 QUERY_STRING 则重定向到页面

  • 0

实际上,如果 URL 不包含QUERY_STRING ,请告诉我如何重定向到 /page.php 。例外是 /page.php 本身

例子:

从http://site.com到http://site.com/page.php

从http://site.com/page2/到http://site.com/page.php

.htaccess
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5