我有两个数组,数组A包含一个长列表,其中包含一些我想删除的元素.数组B是我希望从数组A中删除的那些元素的完整列表.
实现这一目标的最有效方法是什么?
我是初学者codeigniter.我的目的是从example_view.php视图的形式获取值,然后在我提交时在result.php视图中显示此结果.
example_view.php(视图)
<html>
<head><title>Test Example View</title></head>
<body>
<h1 align="center">Test Sample CI Framwork</h1>
<?php echo form_open('example/getvalue'); ?>
<input type="text" name="username" value="" size="50" />
<div><input type="submit" value="Submit" name="submit"/></div>
<?php echo form_close(); ?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
result.php(视图)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php echo 'Your new value is '.$value;?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
使用example.php(控制器)
<?php
class Example extends Controller {
function Example()
{
parent::Controller();
$this->load->helper('form');
$this->load->helper('url');
}
function index() …Run Code Online (Sandbox Code Playgroud) 在最后两条评论之后,我将丢弃我的真实代码,也许它会有所帮助:
这是登陆控制器:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Businessbuilder extends CI_Controller {
function __construct()
{
parent::__construct();
}
function index()
{
$RTR = $GLOBALS["RTR"];
// import the necessary libraries
$this->load->model("site_pages");
$RTR = $GLOBALS["RTR"];
// get the current site
$site = current_site();
// get the requesting url
$class = $RTR->uri->rsegments[1];
$function = $RTR->uri->rsegments[2];
// get the current function and class
$current_method = explode("::", __METHOD__);
// get the real class name that is going to be called
$site_page …Run Code Online (Sandbox Code Playgroud) 我正在尝试将参数传递给codeigniter中的控件,但我找不到404页面错误,我没有得到它,我做了指南说的:https://www.codeigniter.com/user_guide/一般/ controllers.html#传球-URI段到您的方法
当我删除索引函数中的参数并只访问控制器一切正常,但我无法传递值...
以下是我尝试发送参数的代码: http://mysite/123
<?php
class Main extends Controller {
function index($username) {
echo $username;
}
}
?>
Run Code Online (Sandbox Code Playgroud)
如何从codeigniter获取有关此错误的更多信息?
谢谢.
我有我的页面的HTML结构,如下所示.我添加了所有元标记,但仍然无法从我的网站上抓取任何信息.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<meta http-equiv="Content-Type" content="text/html;" charset=utf-8"></meta>
<title>My Site</title>
<meta content="This is my title" property="og:title">
<meta content="This is my description" property="og:description">
<meta content="http://ia.media-imdb.com/images/rock.jpg" property="og:image">
<meta content="<MYPAGEID>" property="fb:page_id">
.......
</head>
<body>
.....
Run Code Online (Sandbox Code Playgroud)
当我在facebook调试器(https://developers.facebook.com/tools/debug)中输入URL时,我收到以下消息:
Scrape Information
Response Code 404
Critical Errors That Must Be Fixed
Bad Response Code URL returned a bad HTTP response code.
Errors that must be fixed
Missing Required Property The 'og:url' property is required, but not present.
Missing …Run Code Online (Sandbox Code Playgroud) 我在我的PHP项目中尝试分页,codeigniter有自己的类叫做"分页",我已经使用过了.现在我的视图页面中有一个页面链接.但是所有数据都打印在一个页面中,这是我的代码..
$mydata = array('mydata' => $this->Admin_model->view_job_posts());
$this->load->library('pagination');;
$config['base_url'] =site_url('/admin/view_job_posts/');
$config['total_rows'] = count($mydata["mydata"]);
$config['per_page'] = 1;
$config['num_links'] = 2;
$config['uri_segment'] = 2;
$this->pagination->initialize($config);
$mydata['links'] = $this->pagination->create_links();
$this->load->view('pages/admin_view_jobs', $mydata);
Run Code Online (Sandbox Code Playgroud)
帮帮我们!
我从db到dropdown的显示数据有困难.
这是我尝试过的:
Model.php
public function __construct()
{
parent::__construct();
}
function getAllGroups()
{
/*
$query = $this->db->get('location');
foreach ($query->result() as $row)
{
echo $row->description;
}*/
$query = $this->db->query('SELECT description FROM location');
foreach ($query->result() as $row)
{
echo $row->description;
}
//echo 'Total Results: ' . $query->num_rows();
}
Run Code Online (Sandbox Code Playgroud)
Controller.php这样
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Delivery_controller extends CI_Controller{
public function __construct()
{
parent::__construct();
$this->load->model('delivery_model');
}
public function index()
{
$data['title']= 'Warehouse - Delivery';
$this->load->view('include/header',$data);
$this->load->view('include/navbar',$data);
$this->load->view('delivery_view', $data);
$this->load->view('include/sidebar',$data); …Run Code Online (Sandbox Code Playgroud) 我一直想知道在模型中用OO风格编写代码的正确方法是什么.当然,您可以使用从DB检索数据然后映射到模型级变量的函数.但是,当您在模型中尝试从BD获取其他数据时,此方法会变得违反直觉.例如:
class User extends CI_Model {
$id, $name, $age .... ;
public function get_user_from_db_with_id($id) {
...
// get data and map to variable.
}
public function get_all_users() {
// return all users in db
}
}
Run Code Online (Sandbox Code Playgroud)
控制器中的某个地方:
$user = new User();
$ben = $user->get_user_from_db_with_id($id);
// this does not make sense!!
$all_user = $ben->get_all_users();
Run Code Online (Sandbox Code Playgroud)
有什么想法或评论吗?
提前致谢!
好的,我花了3天时间试图找出这里发生了什么,我很难过.
该网站使用CI构建.(http://horizoneslchina.com)
有一段时间,无论何时在中国,我都会得到不允许的关键人物.
我使用以下内容扩展了核心Input类:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Input extends CI_Input {
function _clean_input_keys($str)
{
$config=&get_config('config');
if(!preg_match("/^[".$config['permitted_uri_chars']."]+$/i",rawurlencode($str)))
{
exit('Disallowed Key Characters. '.$str);
}
//CleanUTF-8ifsupported
if(UTF8_ENABLED===TRUE)
{
$str=$this->uni->clean_string($str);
}
return $str;
}
}
/* End of file My_Input.php */
Run Code Online (Sandbox Code Playgroud)
它似乎解决了这个问题,但现在我的情况是没有一个会话将保持不变.当中国某人登录并尝试访问任何安全页面时,它会立即终止会话.
这在澳大利亚不会发生,在印度也不会发生.我能找到的唯一区别是在中文系统上,逗号放在会话名称前面.EG,_ci_session和上面的函数之前把它作为问题抛弃了.
有没有人对此有任何想法?
嗨,我有点新手,我想问一下这里有代码签名框架和PHP的专家.
如何在php本机查询中使用mysqli驱动程序?例如.
我的代码:
模型
class Home_model extends CI_Model{
public function getusers(){
$q = "SELECT * FROM `users`";
return $r = mysqli_query($q);
}
}
Run Code Online (Sandbox Code Playgroud)
控制器:
class Home extends CI_Controller{
public function iterateuser(){
while($row = mysqli_fetch_object($this->Home_model->getusers())){
echo $row->username;
}
}
Run Code Online (Sandbox Code Playgroud)
我上面的代码是一个错误,报告称"mysqli_query至少需要2个参数".在codeigniter中是否有一种方法可以传递mysqli_query()第一个参数上的链接,如php.net文档中所述http://php.net/manual/en/mysqli.query.php
codeigniter ×10
php ×6
controller ×1
facebook ×1
model ×1
mysql ×1
mysqli ×1
oop ×1
opengraph ×1
pagination ×1
session ×1