我已经搜索了很多,以找到一个使用MySQL表数据作为数据源生成Google Chart的好例子.我搜索了几天,并意识到使用PHP和MySQL的组合生成Google Chart(饼图,条形图,列,表)的示例很少.我终于设法让一个例子起作用了.
我之前收到过StackOverflow的很多帮助,所以这次我会回复一些.
我有两个例子; 一个使用Ajax而另一个不使用.今天,我只展示非Ajax示例.
用法:
Requirements: PHP, Apache and MySQL
Installation:
--- Create a database by using phpMyAdmin and name it "chart"
--- Create a table by using phpMyAdmin and name it "googlechart" and make
sure table has only two columns as I have used two columns. However,
you can use more than 2 columns if you like but you have to change the
code a little bit for that
--- Specify column names as follows: "weekly_task" and … 我正在研究一个 ElasticSearch (6.2) 项目,其中index有很多keyword字段,并且它们被标准化lowercase过滤器进行了执行不区分大小写的搜索。搜索工作良好并返回规范化字段的实际值(不是小写)。但是,聚合不返回字段的实际值(返回小写)。
以下示例取自 ElasticSearch 文档。
https://www.elastic.co/guide/en/elasticsearch/reference/master/normalizer.html
创建索引:
PUT 指数
{
“设置”:{
“分析”: {
“规范化”:{
“my_normalizer”:{
"类型": "自定义",
"char_filter": [],
“过滤器”:[“小写”,“asciifolding”]
}
}
}
},
“映射”:{
“_doc”:{
“特性”: {
“富”:{
“类型”:“关键字”,
"normalizer": "my_normalizer"
}
}
}
}
}
插入文档:
PUT 索引/_doc/1
{
"foo": "酒吧"
}
PUT 索引/_doc/2
{
"foo": "巴兹"
}
聚合搜索:
获取索引/_search
{
“大小”:0,
“aggs”:{
“foo_terms”:{
“条款”:{
“字段”:“foo”
}
}
}
}
结果:
{
“拿”:43,
“timed_out”:假,
“_shards”:{
“总”:1,
“成功”:1,
“跳过”:0,
“失败”:0
}, … 这似乎Laravel分页DEOS不受条款与组正常工作.例如:
$users = Subject::select(DB::raw('subjects.*, count(user_subjects.id) as total_users'))
->join('user_subjects', 'user_subjects.subject_id', '=', 'subjects.id')
->whereNull('user_subjects.deleted_at')
->groupBy('subjects.id')
->orderBy('subjects.updated_at', 'desc')
->paginate(25);
生成
select subjects.*, count(user_subjects.id) as total_users
from `subjects` inner join `user_subjects` on `user_subjects`.`subject_id` = `subjects`.`id`
where `subjects`.`deleted_at` is null and `user_subjects`.`deleted_at` is null
group by `subjects`.`id`
order by `subjects`.`updated_at` desc
值得注意的是,没有limit对查询子句.
如果没有GROUP BY查询子句工作正常:
$users = Subject::select(DB::raw('subjects.*, count(user_subjects.id) as total_users'))
->join('user_subjects', 'user_subjects.subject_id', '=', 'subjects.id')
->whereNull('user_subjects.deleted_at')
->orderBy('subjects.updated_at', 'desc')
->paginate(25);
产生了以下查询:
select subjects.*, count(user_subjects.id) as total_users …
我目前正在开发一个应用程序,我必须使用几页SSL.例如,登录,注册页面.然而,当协议之间进行切换https来http,Laravel会话不被传输通过HTTP.
是否有任何解决方案,Laravel将保留两个协议的会话.
我在我的MAMP开发环境中安装了Imagemagick扩展,并且PHP信息显示正确安装了imagemagick.但是,我收到以下异常:
PHP Fatal error: Uncaught exception 'ImagickException' with message
'Unable to read the file:
/Applications/MAMP/htdocs/image/demo.pdf'
in /Applications/MAMP/htdocs/image/index.php:8
Stack trace:
#0 /Applications/MAMP/htdocs/image/index.php(8): Imagick->__construct('/Applications/M...')
#1 {main}
thrown in /Applications/MAMP/htdocs/image/index.php on line 8
源代码:
$pdf_file = '/Applications/MAMP/htdocs/image/demo.pdf';
echo $pdf_file;
$save_to = '/Applications/MAMP/htdocs/image/demo.jpg';
$img = new imagick($pdf_file);
//reduce the dimensions - scaling will lead to black color in transparent regions
$img->scaleImage(800,0);
//set new format
$img->setImageFormat('jpg');
//save image file
$img->writeImages($save_to, false);

编辑1:
我brew用来管理包.
我的MAMP配置:
Imagick扩展(php.ini):
[imagick] extension="/usr/local/Cellar/php55-imagick/3.1.0RC2/imagick.so"
envvars中:
路径: …
如何在两台服务器之间共享通用配置.我的应用程序支持http和https(少数页面),我目前正在使用fastcgi_param来保存敏感信息,如数据库名称和密码.我如何共享服务器的位置和fastcgi_param(80,443).
server {
listen 80;
server_name example.com;
}
server {
listen 443 ssl;
server_name example.com;
root /home/forge/example.com/public;
# FORGE SSL (DO NOT REMOVE!)
ssl on;
ssl_certificate /etc/nginx/ssl/example.com/304/server.crt;
ssl_certificate_key /etc/nginx/ssl/example.com/304/server.key;
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/example.com-error.log error;
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_param ENV "production";
fastcgi_param DB_HOST "127.0.0.1";
fastcgi_param … Laravel最酷的功能之一是,如果发生验证错误,Laravel会预先填写表单字段.但是,如果页面包含more than one form,并且表单字段包含same name,则Laravel会预填充所有内容forms fields.
例如:
我有一个页面,我有两个表单来创建新用户或任何其他.
<h1>Create user1</h2>
{{ Form::open(array('url' => 'foo/bar')) }}
{{ Form::text('name', null) }}
{{ Form::email('email', null) }}
{{ Form::close() }}
</h1>Create user2</h1>
{{ Form::open(array('url' => 'foo/bar')) }}
{{ Form::text('name', null) }}
{{ Form::email('email', null) }}
{{ Form::close() }}
Run Code Online (Sandbox Code Playgroud)
调节器
class UsersController extends BaseController
{
public function store()
{
$rules = [
'name' => 'required',
'email' => 'required'
];
$validation = Validator::make(Input::all(), $rules);
if ($validation->fails()) {
return Redirect::back()->withInput()->withErrors($validation);
} …Run Code Online (Sandbox Code Playgroud) 我正在为我的一个客户建立一个网站,他们想要一个功能进入他们的网站,如下所示:
当人们点击下载链接时,会出现一个表单(联系表单7),在访问者提交详细信息后,它将重新定向到下载链接.
通过使用以下附加设置到联系表单7,我可以在表单提交后重新指向新页面.
on_sent_ok: "location = 'http://example.com/';"
Run Code Online (Sandbox Code Playgroud)

但是,他们有10个文件,我需要更改重定向链接10次以触发相应文件的下载.我可以使用10个非常脏的联系表格来完成.
有什么办法可以动态更改重定向URL吗?
例如,
http://example.com/?id=1
http://example.com/?id=2
<?php
$id = $_GET['id'];
$url= "http://example.com/id=?". $id;
?>
Run Code Online (Sandbox Code Playgroud)
有没有办法用$ url更改以下位置?
on_sent_ok: "location = 'http://example.com/';"
Run Code Online (Sandbox Code Playgroud) 我正在开展一个项目,我必须验证BECS字符.批量电子结算系统(BECS)仅允许使用以下字符.
BECS字符集
Type Description
Numeric 0 to 9
Alphabetic Uppercase A to Z and Lowercase a to z
+ Plus sign
- Minus sign or hyphen
@ At sign
SP Blank space
$ Dollar sign
! Exclamation mark
% Percentage sign
& Ampersand
( Left Parenthesis
) Right Parenthesis
* Asterik
. Period or decimal point
/ Solidus (slash)
# Number Sign (Pound or Hash)
= Equal Sign
: Colon
; Semicolon
? Question mark
, Comma
’ Apostrophe
[ …Run Code Online (Sandbox Code Playgroud)