小编nie*_*lsv的帖子

选择文本等于的div

我想选择值为ex的div."5".
这是我的情况:

我有这样的div:

<div class="element">
    <div class="number>5</div>
    <div class="symbol">..</div>
</div>
<div class="element">
    <div class="number>6</div>
    <div class="symbol">..</div>
</div>
...
Run Code Online (Sandbox Code Playgroud)

现在我想选择div witch class = number,其中值等于一堆div中的5.
我怎么能以最好的方式做到这一点?

html javascript jquery

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

反复 - 获取发票PDF(pdf from pdf string)

我正在努力为我的客户收费.但是如何获得发票pdf?
到目前为止我所拥有的是一张包含发票的表格.我显示发票的状态,计划,开始日期,结束日期.然后我也有这样的链接:

/用户/ invoicepdf/invoicenr/1502

该链接转到我的invoicepdfaction并发送invoicenr参数.

在我的invoicepdfaction中我有这个:

public function invoicepdfAction() {
    header('Content-Type:', 'application/pdf');
    header('Content-Disposition:', 'inline;');

    $request = $this->getRequest();
    $invoice_number = $request->getParam('invoicenr');

    try {
        $pdf = Recurly_Invoice::getInvoicePdf($invoice_number, 'en-US');
        var_dump($pdf);
    } catch (Recurly_NotFoundError $e) {
        print "Invoice not found.\n";
    }
}
Run Code Online (Sandbox Code Playgroud)

我的var_dump显示了这个.

但是如何在浏览器中显示pdf?(或直接下载)

php pdf zend-framework invoice recurly

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

使用变量外部switch语句+ asp.net mvc

在我的控制器中的索引操作中,我有:

public ActionResult Index(string sortOrder)
{
    var model;
    ViewBag.CitySortParm = String.IsNullOrEmpty(sortOrder) ? "City_desc" : "";
    switch (sortOrder)
    {
        case "City_desc":
            model = this.UnitOfWork.AddressRepository.Get().OrderBy(a => a.City);
            break;
    }
    return View(model);
}
Run Code Online (Sandbox Code Playgroud)

这不起作用,我总是得到错误: Implicitly-typed local variables must be initialized

为什么这不起作用,我该如何解决这个问题呢?

c# asp.net variables asp.net-mvc

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

用值替换键(但不要翻转)

我有这样一个数组:

["AF"]=> string(11) "Afghanistan" 
["002"]=> string(6) "Africa" 
["AL"]=> string(7) "Albania"
 ...
Run Code Online (Sandbox Code Playgroud)

现在我想要一个像这样的数组:

["Afghanistan"]=> string(11) "Afghanistan" 
["Africa"]=> string(6) "Africa" 
["Albania"]=> string(7) "Albania"
 ...
Run Code Online (Sandbox Code Playgroud)

这可能不通过它们循环吗?(这是否有一个PHP功能?)当我搜索谷歌时,我找到了arary_flip,但那是切换键和值...

php arrays function

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

会话到期时重定向到登录页面+ silex

我想在会话过期时重定向到我的登录页面.现在发生了什么:

例如,当您登录并在仪表板上时,您会在右上角看到您的用户名.但是当你在2小时左右没有做任何事情然后刷新时,你会得到一个错误,即无法访问NULL的属性'username'.这是因为你已经注销了...但是当我的会话到期时如何重定向到登录页面?

我知道如何增加过期时间,但我不知道如何重定向..

php session redirect symfony silex

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

Ajax路由脱机工作,而不是服务器+ Silex

我在服务器上遇到ajax调用问题.这是我的完整routes.php文件:

<?php
$app->post('translations/get/trans', 'Translations\Controller\IndexController::ajaxGetTagsTranslations')->bind('translations.gettrans');

$app->get('/{_locale}/dashboard', 'Dashboard\Controller\IndexController::indexAction')->bind('dashboard.index');

$app->match('/api/todo/{user}/{accessKey}', 'Api\Controller\IndexController::todoAction')->method('POST|GET');
$app->match('/api/getdailymessage/{user}/{accessKey}', 'Api\Controller\IndexController::getDailyMessageAction')->method('POST|GET');
$app->match('/api/todo/out', 'Api\Controller\IndexController::todooutAction')->method('POST|GET');
$app->match('/api/finisharea', 'Api\Controller\IndexController::finishAreaAction')->method('POST|GET');
$app->match('/api/activity', 'Api\Controller\IndexController::activityAction')->method('POST|GET');
$app->match('/api/supplier', 'Api\Controller\IndexController::suppliersAction')->method('POST|GET');
$app->match('/api/translations', 'Api\Controller\IndexController::translationsAction')->method('POST|GET');
$app->match('/api/serverdatetime', 'Api\Controller\IndexController::serverDateTimeAction')->method('POST|GET');
$app->match('/api/dailymessage', 'Api\Controller\IndexController::dailyMessageAction')->method('POST|GET');
$app->match('/api/settings', 'Api\Controller\IndexController::settingsAction')->method('POST|GET');
$app->match('/api/providedby', 'Api\Controller\IndexController::providedByAction')->method('POST|GET');
$app->match('/api/presentations', 'Api\Controller\IndexController::presentationsAction')->method('POST|GET');
$app->match('/api/login', 'Api\Controller\IndexController::loginAction')->method('POST|OPTIONS|HEAD|GET');

$app->get('/{_locale}/hosts/list', 'Hostess\Controller\IndexController::listAction')->bind('hosts.list');
$app->match('/{_locale}/hosts/detail/{id}/{range}', 'Hostess\Controller\IndexController::detailAction')->method('GET')->bind('hosts.detail');
$app->match('/{_locale}/hosts/edit/{id}', 'Hostess\Controller\IndexController::editAction')->method('GET|POST')->bind('hosts.edit');
$app->post('/hosts/gethosts', 'Hostess\Controller\IndexController::ajaxGetHosts')->bind('hosts.gethosts');

$app->get('/{_locale}/segments/list', 'Segments\Controller\IndexController::listAction')->bind('segments.list');
$app->get('/{_locale}/segments/view/{id}', 'Segments\Controller\IndexController::viewAction')->bind('segments.view');
$app->match('/{_locale}/segments/edit/{id}', 'Segments\Controller\IndexController::editAction')->method('GET|POST')->bind('segments.edit');
$app->post('/segments/order', 'Segments\Controller\IndexController::ajaxUpdateOrderAction')->bind('segments.order');
$app->post('/segments/getsegments', 'Segments\Controller\IndexController::ajaxGetSegments')->bind('segments.getsegments');

$app->post('/segments/gethosts', 'Segments\Controller\IndexController::ajaxGetHostsSegment')->bind('segments.gethosts');
$app->post('/segments/updatehosts', 'Segments\Controller\IndexController::ajaxUpdateHostsSegment')->bind('segments.updatehosts');

$app->match('/{_locale}/subarea/edit/{segmentcode}/{deelgebied}', 'Segments\Controller\IndexController::editSubareaAction')->method('GET|POST')->bind('subarea.edit');

$app->get('/{_locale}/presentations/list', 'Presentations\Controller\IndexController::listAction')->bind('presentations.list');
$app->match('/{_locale}/presentations/upload', 'Presentations\Controller\IndexController::uploadAction')->method('GET|POST')->bind('presentations.upload');
$app->post('/presentations/deletepresentation', 'Presentations\Controller\IndexController::ajaxDeletePresentation')->bind('presentations.deletepresentation');

$app->match('/{_locale}/translations/list', 'Translations\Controller\IndexController::listAction')->method('GET|POST')->bind('translations.list');
$app->get('/translations/inserttrans', 'Translations\Controller\IndexController::insertTransJSON')->bind('translations.inserttrans');

$app->match('/{_locale}/settings/list', 'Settings\Controller\IndexController::listAction')->method('GET|POST')->bind('settings.list');

$app->match('/{_locale}/history/index', 'History\Controller\IndexController::indexAction')->method('GET|POST')->bind('history.index');

$app->get('/404', 'Api\Controller\IndexController::indexAction');
Run Code Online (Sandbox Code Playgroud)

我遇到了第一条路线的问题.我首先得到的是以下内容:translations/gettrans但这不起作用.所以现在我尝试了,translations/get/trans但也没有这样做.我总是得到404错误(未找到).当我检查路由时,他可以找到路线:

在此输入图像描述

但为什么这不起作用?

php ajax routes symfony silex

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

FPDI 在 ... 字符后换行

我正在创建一个FPDI PDF。这就是我现在所做的:

libraries_load('fpdi');

$pdf = new FPDI();  

$path = drupal_get_path('theme', 'xmed') . '/docs/verkocht_template.pdf';

$pdf->setSourceFile(realpath($path)); 
$tplIdx = $pdf->importPage(1, '/MediaBox');

$pdf->addPage();
$pdf->useTemplate($tplIdx, 0, 0, 210);

$path = drupal_get_path('theme', 'xmed') . '/fonts/lato.php';

$pdf->AddFont('lato-light-webfont','','lato-light-webfont.php');
$pdf->SetFont('lato-light-webfont', '', 14);
$pdf->SetTextColor(0, 0, 0);

$pdf->SetXY(47, 71);
$pdf->Write(0, $name);
Run Code Online (Sandbox Code Playgroud)

我还在我的 PDF 上放置了一些其他变量。这是现在的结果:

在此处输入图片说明

但是正如你所看到的 $name 变量太长了...。我试过这个:

$naam = wordwrap($naam, 20);
Run Code Online (Sandbox Code Playgroud)

但这给了我这个结果:

在此处输入图片说明

解决此问题的最佳解决方案是什么?

pdf pdf-generation fpdf fpdi

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

第二个td高于第一个td + html表

我有这样一张桌子:

<table>
    <tbody>
        <tr></tr>
        <tr></tr>
        <tr class="TableContent">
            <td class="shouldbeunderTableMenu"></td>
            <td class="TableMenu"></td>
        </tr>
    </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

正如你所看到的,我有一个类等于的td TableMenu.我想用td 将td 定位在td 之上shouldbeunderTableMenu.

这样第一个td垂直位于第二个td之下.图片澄清:

在此输入图像描述

但是我怎么能这样做呢?

javascript css jquery html-table

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

Laravel 5 迁移 - 外键约束失败

我在运行迁移时遇到问题。我有一个包含一些表的 mysql 数据库。具体表是product_blender。表中的一些字段是这样的:

  • 身份证(PK)
  • area_id (FK)
  • 居民(varchar)
  • heat_type_id (FK)
  • ...

现在我想创建另一个名为installateur_types. 该表需要包含一个PK和一个varchar 字段。我还想在表中创建一个FKproduct_blender到我新创建的表的ID

这就是我所做的:

创建迁移以创建表:

public function up()
{
    Schema::create('installateur_types', function(Blueprint $table)
    {
        $table->increments('id');
        $table->string('type');
    });
}

public function down()
{
    Schema::drop('installateur_types');
}
Run Code Online (Sandbox Code Playgroud)

运行迁移,这是成功的。表是用正确的字段创建的。

然后我创建了迁移以将 FK 字段添加到 product_blender 表中

public function up()
{
    Schema::table('product_blenders', function ($table) {
        $table->integer('installateurtype_id')->unsigned();
        $table->foreign('installateurtype_id')->references('id')->on('installateur_types')->onDelete('cascade');
    });
}

public function down()
{
    //
}
Run Code Online (Sandbox Code Playgroud)

当我现在运行迁移时,出现以下错误: 在此处输入图片说明

我究竟做错了什么?

mysql database foreign-keys laravel laravel-5

0
推荐指数
1
解决办法
2423
查看次数

删除.git /后修复git repo

情况就是这样:

我不小心删除了项目中的.git文件夹.如何撤消这一点,没有后果?

git github

0
推荐指数
1
解决办法
87
查看次数