小编626*_*626的帖子

MySQL使用逗号分隔值连接两个表

我有2个表格如下

备注表

??????????????????????????????
? nid      ?    forDepts     ?
??????????????????????????????
? 1        ? 1,2,4           ?
? 2        ? 4,5             ?
??????????????????????????????
Run Code Online (Sandbox Code Playgroud)

职位表

??????????????????????????????
? id       ?    name         ?
??????????????????????????????
? 1        ? Executive       ?
? 2        ? Corp Admin      ?
? 3        ? Sales           ?
? 4        ? Art             ?
? 5        ? Marketing       ?
??????????????????????????????
Run Code Online (Sandbox Code Playgroud)

我希望查询我的Notes表并将'forDepts'列与Positions表中的值相关联.

输出应该是:

    ?????????????????????????????????????????
    ? 1        ? Executive, Corp Admin, Art ?
    ? 2        ? Art, Marketing             ?
    ?????????????????????????????????????????
Run Code Online (Sandbox Code Playgroud)

我知道数据库应该规范化,但我无法更改此项目的数据库结构.

这将用于导出带有以下代码的excel文件.

<?PHP

    $dbh1 = mysql_connect($hostname, $username, …
Run Code Online (Sandbox Code Playgroud)

php mysql left-join group-concat find-in-set

38
推荐指数
2
解决办法
3万
查看次数

使用 zeit/pkg 打包 Node-Red

我在 node-red 项目中使用zeit/pkg时遇到了一些问题。以下是重现问题的步骤:

  1. git clone https://github.com/node-red/node-red.git
  2. cd node-red
  3. npm install
  4. npm run build

  5. 在构建命令后,我将以下内容添加到我的 package.json 文件中:

    "pkg": {
       "assets": [
          "./red/**/*"
       ],
       "scripts": [
          "./red/**/*.js"
       ]
    }
    
    Run Code Online (Sandbox Code Playgroud)
  6. 运行命令 pkg .

运行后,pkg .我收到以下错误:

C:\xampp\htdocs\node-red>pkg .
> pkg@4.3.4
> Targets not specified. Assuming:
  node8-linux-x64, node8-macos-x64, node8-win-x64
> Warning Cannot resolve 'path.join(__dirname, '..', '..', 'package.json')'
  C:\xampp\htdocs\node-red\red\runtime\index.js
  Dynamic require may fail at run time, because the requested file
  is unknown at compilation time and not included into executable.
  Use a …
Run Code Online (Sandbox Code Playgroud)

packaging node.js node-red zeit-pkg

5
推荐指数
0
解决办法
545
查看次数

仅更新 ON DUPLICATE KEY UPDATE 的更改值

我有一个复选框列表,这些复选框被分配了值 1 或 0,所有这些都在 $_POST 变量中传递。

我当前的 sql 语句正确插入了所有这些内容,但是当我更改值并再次运行 sql 语句时,它会更新所有项目的“updated_at”列。

有没有办法只更新更改的值,这样就不会更新每个条目的“updated_at”列?id 是我的主键,site_id 是唯一的。

SQL语句:

        $sql = "INSERT INTO admin_sites2 (site_id,created_at,active)
                VALUES ('$key',now(),'$value')
                ON DUPLICATE KEY
                UPDATE active = $value,
                updated_at = now()
               ";
Run Code Online (Sandbox Code Playgroud)

php mysql insert-update sql-update

4
推荐指数
1
解决办法
2822
查看次数

Gmail CSS样式

我在使用Gmail时遇到了一些CSS问题.我的HTML电子邮件具有响应能力,可以在iPhone上运行,但在发送到Gmail时,它会显示"mobile_toolbar"和"full_toolbar".我需要摆脱移动工具栏,以便为Gmail桌面正确格式化电子邮件.

我已经尝试过使用display:none!important但它无效.

谢谢!

CSS:

<style type="text/css">
.ReadMsgBody {width: 100%; background-color: #ffffff;}
.ExternalClass {width: 100%; background-color: #ffffff;}
body     {width: 100%; background-color: #ffffff; margin:0; padding:0; -webkit-font-smoothing: antialiased;font-family:Arial}
table {border-collapse: collapse;}
p {font-family: Arial, serif;}
a {font-family: Arial, serif;}

@media only screen and (max-width: 640px)  {
                body[yahoo] .deviceWidth {width:440px!important; padding:0;}    
                body[yahoo] .center {text-align: center!important;}  
                                    #full_toolbar {display:none !important;}



                #mobile_toolbar {display:block; background:white;}

                #mobile_toolbar a {text-decoration:none;}
        }

@media only screen and (max-width: 479px) {
                body[yahoo] .deviceWidth {width:280px!important; padding:0;}    
                body[yahoo] .center {text-align: center!important;}  
        }

            @media screen and …
Run Code Online (Sandbox Code Playgroud)

html css email gmail html-email

2
推荐指数
1
解决办法
6606
查看次数

jQuery AJAX将url作为字符串传递

我有一个ajax函数,它将一串变量传递给我的脚本,但我有一个变量,需要包含一个带参数的完整url.

会发生什么是var1和var2成为$ _POST变量,但我需要将整个url变量保存为字符串.

var url = "http://domain.com/index.php?var1=blah&var2=blah";

var dataArray = "rooftop_id=" +rooftop_id+ "&url=" +url;

        $.ajax({
            type: "POST",
            url: "/scripts/error_check.php",
            data: dataArray,
            dataType: 'json'
        }); 
Run Code Online (Sandbox Code Playgroud)

我希望我的$ _POST变量看起来像这样:

$_POST['rooftop_id'] would be '1234'
$_POST['url'] would be 'http://domain.com/index.php?var1=blah&var2=blah'
Run Code Online (Sandbox Code Playgroud)

提前致谢!

javascript php ajax jquery

2
推荐指数
1
解决办法
1万
查看次数