这是我的功能.这很简单.
function load_data() {
$query = $this->db->query('SELECT * FROM configurations WHERE username="' . $this->session->userdata('username') . '"');
return $query;
}
Run Code Online (Sandbox Code Playgroud)
我的控制器有这行代码:
$data['query'] = $this->configurations->load_data();
Run Code Online (Sandbox Code Playgroud)
在我看来,我试过:
foreach($query->result_array() as $row) {
echo $row->first;
}
Run Code Online (Sandbox Code Playgroud)
但我得到一个错误,我试图获得非对象的属性.查询是否作为对象从模型返回?
我有关于PHP OOP的语法问题.
我有两个功能.
public function setBody($body) {
$this->body = $body;
}
public function return_value($value) {
return $value;
}
Run Code Online (Sandbox Code Playgroud)
$ body在函数中声明更高.如果我想在setBody上调用return_value函数(我意识到什么都没做 - 这只是我用来学习的一个例子),那么它的语法是什么?
我试过了$this->body = return_value($body),但没用.我也尝试return_value($this->body)过第二行,也没用.
在此先感谢您的帮助.
如果有人在浏览器中启用了Cookie,最好的方法是什么?我试过了:
<?php
setcookie('cookies','yes',time()+7200);
if (!isset($_COOKIE['cookies'])) {
echo '<div class="error" style="float:right;">You must enable cookies and Javascript to use this site.</div>';
} else {
echo '';
}
?>
Run Code Online (Sandbox Code Playgroud)
但有时即使启用了cookie,它也会显示警报.如果没有启用cookie,我只想要一个警报.
我有一张地图上有多个位置.位置根据显示的页面在运行时确定(它们是我们经销商的位置,因此它们根据经销商ID而变化.(标记显示正常,但现在我想将地图居中,以便将其缩放为包括所有标记的中心和基于显示的标记居中.我该怎么做?现在,手动设置缩放和中心.这是我的代码到目前为止:
<script type="text/javascript">
function initialize() {
var locations = [
<?php
$loc = '';
$i = 1;
foreach ($coordinates as $c) {
$loc .= '["' . $c->company . '", ' . $c->latitude . ', ' . $c->longitude . '], ';
$i++;
}
echo substr($loc, 0, -2);
?>
];
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: new google.maps.LatLng(-33.92, 151.25),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < locations.length; i++) { …Run Code Online (Sandbox Code Playgroud) 我正在尝试更新我从Laravel 4中的数据库中提取的用户的密码.以下是我所拥有的:
$user = User::where('username', $username)->get();
if (!empty($user)) {
$user->password = Hash::make($password);
$user->save();
}
Run Code Online (Sandbox Code Playgroud)
但是Laravel告诉我这save是一种未知的方法.我在这做错了什么?
我composer update刚刚跑上了Laravel 4.我试图解决一个问题Input::json(),它在之前的一个问题之后就停止了工作composer update.现在,path()返回一个未定义的函数错误.
泰勒改变了这些吗?如果他们把它们拿出来,有没有人知道它们的替代品?
我找到了一个如何使用Vue路由器的很好的例子.这是app.js文件:
// Telling Vue to use the router
Vue.use(VueRouter)
// Initializing the router with options
var router = new VueRouter({
history: false
});
// Redirect certain routes to other routes
router.redirect({
'/': '/users/list'
})
// Define your routes here.
// NOTE: You'd normally do something
// like require('./home/index.vue') for the component
router.map({
// Not found handler
'*': {
component: {
template:
'<div>' +
'<h1>Not Found</h1>' +
'</div>'
}
},
'/users': {
component: {
template:
'<div>' + // Wrap your views …Run Code Online (Sandbox Code Playgroud) 如何在jQuery中编写一个可以捕获下拉列表值的click事件?我有:
var select = $('select #dealerName');
$(function {
select.click(function {
alert( $('#dealerName').val() );
});
});
Run Code Online (Sandbox Code Playgroud)
我只是想要获得价值 - 这就是我提醒它的原因.点击功能会是什么样子?我的下拉列表中的ID是"dealerName".以上内容并未提醒任何事情.
我有一个非常基本的问题.我的代码无法正常工作,因为它无法识别调用jQuery的div.
我尝试使用this.id或警告它,$(this).attr('id')并且在点击有问题的div时我没有收到警报.但是当我点击其他元素时,我会收到警报.这是我的HTML:
<div id="map"><img src="../../images/map2.jpg" /></div>
<div id="n_america" style="position:absolute;top:171px;"><img src="../../images/maps/north_america.jpg" /></div>
<div id="euro" style="position:absolute;top:171px;"><img src="../../images/maps/eurafrica.jpg" /></div>
<div id="table-bottom" style="position:absolute; margin-top:-70px;">
<div id="table-btm-title" style="width:255px;"><a id="north_america" href="#">North America and Latin America</a></div>
<div id="table-btm-title" style="width:147px;"><a id="eurafrica" href="#">Europe and Africa</a></div>
<div id="table-btm-title" style="width:230px; border:none;"><a id="asiapacific" href="#">Asia and South Pacific</a></div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我的jQuery:
$(function(){
$('#n_america').css({ opacity: 0 });
$('#euro').css({ opacity: 0 });
$('#north_america').click(function() {
$('#map').animate({ opacity: 0}, 'slow');
$('#n_america').animate({ opacity: 1 }, 'slow');
$('#euro').animate({ opacity: 0 }, 'slow');
$('#n_america').imagemap([
/...
]);
}); …Run Code Online (Sandbox Code Playgroud) 我需要比较两个Unix时间戳,我在数学上遇到了麻烦.我知道Unix时间戳是自1970年1月1日以来的秒数.但是我的数学运算出错了.我正在尝试检测文件上次修改时间是否为3分钟.这是我的代码:
if (file_exists($filename)) {
$filemodtime = filemtime($filename);
}
$three_min_from_now = mktime(0, 3, 0, 0, 0, 0);
if (time() >= $filemodtime + $three_min_from_now) {
// do stuff
} else {
// do other stuff
}
Run Code Online (Sandbox Code Playgroud)
但是else条款仍然令人满意,而不是if,即使if应该是真的.我认为这个问题是我的数学问题.有人可以帮忙吗?谢谢.
我需要向具有背景图像的类中添加填充。但是,这样做时,填充不会添加到背景图像中,而只是添加到锚点中。我究竟做错了什么?这是我的CSS:
.heart {
width:200px;
height:18px;
background:url(/images/content/digital-learning/course-library/sprite-favorites.png) 0px 18px repeat-y;
padding-left: 20px;
display:block;
}
Run Code Online (Sandbox Code Playgroud) 我有一个页面,我使用PHP while循环来回应我们的经销商的名称和地址.对于电子邮件链接,我希望用户能够单击该链接,然后将其带到通过电子邮件发送给该人的表单.
我知道你不能混用Javascript和PHP,所以如何判断用户点击了哪个链接,以便我可以将该变量传递给下一页的表单?这是我的代码:
<?php while($row = mysql_fetch_array($result)) {
if ($row['active'] == 1) {
?>
<div id="dealer">
<div id="dealername">
<h3 style="float:left;"><?php echo $row['company']; ?></h3><br/>
<p><?php echo $row['address1']; ?><br/>
<?php if($row['address2'] || $row['address3']) {
echo $row['address2'] . ' ' . $row['address3'] . '<br/>'; } ?>
<?php echo $row['city'];
if ($row['state']) {
echo ', ' . $row['state'];
}
echo ' ' . $row['zip']; ?>
<br />
<?php echo $row['country']; ?>
<br />
<br />
Phone: <strong><?php echo $row['phone1']; ?></strong><?php if ($row['phone2']) {
echo ' …Run Code Online (Sandbox Code Playgroud) php ×3
jquery ×2
laravel ×2
laravel-4 ×2
codeigniter ×1
css ×1
google-maps ×1
javascript ×1
oop ×1
session ×1
variables ×1
vue.js ×1