小编Col*_*ock的帖子

CodeIgniter中的大小写不敏感路由

我在CodeIgniter的路由器中写了这个.

$route['companyname'] = "/profile/1";
Run Code Online (Sandbox Code Playgroud)

这工作正常,但当我在URL中键入"CompanyName"时,它不起作用.这是因为大写字符.

我想让这个路由案例不敏感.请建议最好的方法.

router codeigniter

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

在jQuery中减去div高度

今天我有一个简短的问题.这是我的功能:

function checkheight() {
var heightofdiv = $('#checkforheight').height();
$("#centeredbackground").css("min-height",heightofdiv);
}
Run Code Online (Sandbox Code Playgroud)

我的问题是我想得到我的变量heightofdiv,然后减去42像素的答案.所以真的,我希望heightofdiv等于checkforheight减去42像素的高度.如果这是可能的,那将非常感谢帮助.谢谢!

javascript jquery

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

简单的JavaScript登录表单验证

只是一个非常简单的登录和重定向,但由于我将按钮输入类型更改为"submit"而onClick事件更改为onSubmit,因此脚本不会触发.现在一切都只是将用户名和密码作为字符串添加到网址.

<form name="loginform">
    <label>User name</label>
    <input type="text" name="usr" placeholder="username"> 
    <label>Password</label>
    <input type="password" name="pword" placeholder="password">
    <input type="submit" value="Login" onSubmit="validateForm();" />
</form>

<script>
    function validateForm() {
        var un = document.loginform.usr.value;
        var pw = document.loginform.pword.value;
        var username = "username"; 
        var password = "password";
        if ((un == username) && (pw == password)) {
            window.location = "main.html";
            return false;
        }
        else {
            alert ("Login was unsuccessful, please check your username and password");
        }
      }
</script>
Run Code Online (Sandbox Code Playgroud)

javascript html5

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

如何在Codeigniter中生成条形码图像?

如何使用CodeIgniter打印条形码图像?

我是否必须制作自定义库或帮助程序才能生成条形码图像?有没有人知道在CodeIgniter中生成条形码图像的任何库或助手?

php codeigniter barcode

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

如何使用CodeIgniter格式化日期

我想知道我在这里做错了什么.我想date_published在我的查询中格式化该字段,并且我t_string syntax error在我的IDE中获得了一个.

$this->db->select('site_news_articles.article_title, site_news_articles.is_sticky,' date_format('site_news_articles.date_published, 'f jS, Y')');
Run Code Online (Sandbox Code Playgroud)

更新:

function getNewsTitles($category_id) {
    $this->db->select('site_news_articles.article_title, site_news_articles.is_sticky');
    $this->db->select("DATE_FORMAT(site_news_articles.date_published, '%M %e, %Y') as formatted_date", TRUE);
    $this->db->from('site_news_articles');
    $this->db->where('site_news_articles.news_category_id', $category_id); 
    $this->db->where('site_news_articles.is_approved', 'Yes');
    $this->db->where('site_news_articles.status_id', 1);
    $this->db->order_by('site_news_articles.date_published', 'desc');  
    $this->db->limit(10);
    $query = $this->db->get();
    return $query->result_array(); 
}
Run Code Online (Sandbox Code Playgroud)

错误号码:1064

您的SQL语法有错误; 检查与MySQL服务器版本对应的手册,以便在'FROM(site_news_articles)WHERE 附近使用正确的语法site_news_articles.news_category_id= 2 A'在第2行

选择site_news_articles.article_title,site_news_articles.is_sticky,DATE_FORMAT(site_news_articles.date_published,'%M%E,%Y')如FORMATTED_DATE FROM(site_news_articles)WHERE site_news_articles.news_category_id= 2, site_news_articles.is_approved= '是' …

php codeigniter

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

通过jQuery获取META描述

假设我做一个简单的AJAX请求(在jQuery中)就像 geturl.php?url=http://google.com

并且geturl.php是这样的:

<?php
    if($_GET['url'])
    {
        $url=$_GET['url'];
        echo file_get_contents($url);
    }
?>
Run Code Online (Sandbox Code Playgroud)

简单吧?

我如何从jQuery中返回的(非常长的)字符串中获取META描述?

这是我到目前为止所拥有的.是的,我知道,desc是错的.

$.get("geturl.php?url="+url,function(response)
{
    // Loading <title></title>data
    var title=(/<title>(.*?)<\/title>/m).exec(response)[1];
    var desc = $("meta[name=description]").val();
    $("#linkbox").html("<div><b>"+title+"</b><br/>"+url+"<br />Desc: " + desc)
});
Run Code Online (Sandbox Code Playgroud)

php jquery

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

如何在PHP中将字符串转换为符号

如何将密码字符串转换为指定的符号*或其他内容.

我目前正在处理更改密码页面.我想显示密码到页面,我想避免密码被某人忽略,所以我想将密码的字符串转换为符号,如同*相同的长度.像一个例子<input type="password" />.

对不起,我的英语不好...

php

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

下载csv文件

当我们点击该按钮时,我们有一个按钮,所有数据都进入csv文件并下载此csv文件.csv文件创建但下载代码不起作用

$fp = fopen("file\customer-list.csv", "w");
fileName = "file\customer-list.csv";
$filePath = "file\customer-list.csv";
$fsize = filesize("file\customer-list.csv");

if(($_POST['csv_download_list']) == "cm")
{
    fwrite($fp, $csv);
    fclose($fp); 
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header("Content-Disposition: attachment; filename=\"$fileName\"");
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Content-Length: ' . filesize($filePath));
    ob_clean();
    flush();
    $file = @fopen($filePath,"rb");
    if ($file) {
        while(!feof($file)) {
            print(fread($file, 1024*8));
            flush();
        }
    @fclose($file);
}
exit;
Run Code Online (Sandbox Code Playgroud)

php

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

Backbone.js:仅渲染集合中的最后一个模型,显示模型的总数

我有一个基本的backbone.js应用程序,它呈现了一组模型.我想修改为仅渲染最后一个模型,并显示模型总数的数字.到目前为止,这是我的代码:

 var Thing = Backbone.Model.extend({
 });

 var ThingView = Backbone.View.extend({
    el: $('body'),
     template: _.template('<h3><%= title %></h3>'),

     render: function(){
         var attributes = this.model.toJSON();
         this.$el.append(this.template(attributes));
     }
 });


 var ThingsList = Backbone.Collection.extend({
   model: Thing
});

var things = [
  { title: "Macbook Air", price: 799 },
  { title: "Macbook Pro", price: 999 },
  { title: "The new iPad", price: 399 },
  { title: "Magic Mouse", price: 50 },
  { title: "Cinema Display", price: 799 }
];

var thingsList = new ThingsList(things);


var ThingsListView …
Run Code Online (Sandbox Code Playgroud)

javascript backbone.js

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

JSON返回值

目前我遇到从PHP返回一些值到jQuery的问题 - 不知道如何做到这一点

$(document).ready(function(){
  $('#testForm').submit(function(e){
    $.post('submit.php',$(this).serialize(),function(msg){

        $('#submit').val('Submit');

        if(msg.status){
            $('#testForm').html(msg);
        }
        else {
            $('#testForm').html("fail");
        }
    },'json');

});

});

<?php
$name = $_POST['name'];
$email = $_POST['email'];

//echo json_encode(array('status'=>1,'html'=>$name." : ".$email));
echo '{"status":1,'.$name.'}';
?>
Run Code Online (Sandbox Code Playgroud)

我想将name变量值从PHP 返回到jQuery一次status = 1意味着成功,但我仍然没有运气这样做.

php jquery json

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

标签 统计

php ×6

codeigniter ×3

javascript ×3

jquery ×3

backbone.js ×1

barcode ×1

html5 ×1

json ×1

router ×1