告诉我,有什么方法/方法可以检查当前页面是否是 header.tpl、footer.tpl 中的产品?例如:if (is_product) { // do something }
theblackpost's questions
有一个数组:
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加载,它应该看起来像这个:
帮助如何实现这个?
$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 UPDATE
pipeline_name = '$pipelinename'
,那么记录是重复的
我怎样才能简化这段代码。太多的重复。
$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);
现在打开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
有什么出乎意料的。。
我有一个多维数组:
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)
}
}
如何正常填充新数组?
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 * 显示所有内容
$cometime = '2019-09-03 23:40:13';
$gotime = '2019-09-04 12:00:00';
如何以(int)小时计算差异 $gotime - $cometime?
有一个数组:
[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
有一个数组:
$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 倍随机掉出,循环在那里结束。
有一个字符串包含数字,-,它们之间的空格,请参阅:
$string = 50 — 55 см
数字可能会有所不同。
如何删除所有内容并仅保留最后一个数字:55。没有字母,没有空格和破折号?
尝试使用preg_replace('/см/','',$string);
,但我只会删除см
有什么东西弄糊涂了。这是为什么?怎么修?
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 += "...";
}
有一个表格:
<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 值也不能被条件改变。
有这样一个用于创建 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
. 然后创建一个具有相同名称的文件,但它不工作。但是当您从控制台运行脚本时,一切正常。
实际上,这是错误:
/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
body {
background: url(./img/body_alt.jpg) top center no-repeat fixed;
}
图片:1920x1080 像素。在里面<body>
,当然还有内部元素。如何将图像裁剪为 290px 高度?
告诉我如何在 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 的新条目
告诉我如何在.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>
当前请求:
$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
实际上,如果 URL 不包含QUERY_STRING ,请告诉我如何重定向到 /page.php 。例外是 /page.php 本身
例子: