我有这个查询:
$consulta = $this->db->consulta("INSERT INTO prestamo_equipo (id_equipo, id_usuario, fecha_devolucion) VALUES $valor ");
Run Code Online (Sandbox Code Playgroud)
哪里$valor
是('1', '75', 'xs', '2015-12-14'),('1', '75', 'xs', '2015-12-14')
.
$id = $this->db->getInsertId($consulta);
Run Code Online (Sandbox Code Playgroud)
这最后一行,只返回第一个插入ID,而不是另一个,我想要两个插入的id.
这是一些示例HTML:
<div class="parent">
<div class="searchEl"></div>
<div class="searchEl"></div>
<div class="child">
<div class="searchEl"></div>
<div class="searchEl"></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是一个jQuery函数:
$(function(){
$(".parent>.searchEl").each(function(){
$(this).html("Found this one");
});
});
Run Code Online (Sandbox Code Playgroud)
DOM元素最终将如下所示:
<div class="parent">
<div class="searchEl">Found this one</div>
<div class="searchEl">Found this one</div>
<div class="child">
<div class="searchEl"></div>
<div class="searchEl"></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
使用jQuery/Javascript,我如何搜索和查找元素.searchEl
下面的所有元素.parent
,即使它们在另一个子元素中,而不是全局搜索文档$(".searchEl")
?
我希望能够在a中显示整个图像div
.
我在显示background-size
属性设置为的图像时遇到困难contain
- 它不显示整个图像,只显示源图像的完整大小的中心.
码
#header {
background: rgba(0, 0, 0, 0.8);
color: #ccc;
text-align: center;
position: absolute;
top: 0;
left: 0;
width: 100%;
z-index: 3;
padding: 20px 0;
}
#header .logo {
width: calc(100%/3);
height: 75px;
margin: 0 auto;
background-size: contain;
background: url(http://startupweekend.org/wp-content/blogs.dir/1/files/2013/04/CokeLogo1.png) no-repeat center center;
}
Run Code Online (Sandbox Code Playgroud)
<div id="header">
<div class="logo"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
我创建了一个允许我调试PHP脚本的函数,只要将variable($debug
)设置为1
:
function debug($msg) {
if ($debug == 1) {
echo $msg;
} else {
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
这样,在我的脚本顶部(在functions.php
调用文件之前),我写道:
$debug = 1;
Run Code Online (Sandbox Code Playgroud)
启用调试,然后:
debug("Function executed: " . $data);
Run Code Online (Sandbox Code Playgroud)
在某些点上,以便我知道字符串值/在该点的任何内容,所需的响应是屏幕上显示的消息.
但是,无论$debug
字符串的值是什么,我都看不到任何echo
'd语句.
怎么能实现这一目标?
形成:
<form id="register" method="POST" action="pro/register.php">
<input type="text" maxlength="30" placeholder="Username" id="user" /><br />
<input type="email" maxlength="64" placeholder="Email" id="email" /><br />
<input type="password" placeholder="Password" id="pass1" /><br />
<input type="password" placeholder="Confirm Password" id="pass2" /><br />
<input type="submit" value="Register" id="submit_register" />
</form>
Run Code Online (Sandbox Code Playgroud)
pro/register.php
页面:
$user = $_POST['user'];
$email = $_POST['email'];
$pass1 = $_POST['pass1'];
$pass2 = $_POST['pass2'];
//Debug only
echo "<strong>Details:</strong><br>";
echo $user.", ".$email.", ".$pass1.", ".$pass2."<br>";
if($pass1!==$pass2){
header('Location:../login.php?alert=pass');
exit;
}
$hash = hash('sha256', $pass);
include "../inc/functions.php";
$salt = createSalt();
$hash = hash('sha256', $salt . …
Run Code Online (Sandbox Code Playgroud) 我想做什么
我正在尝试显示已上传到频道的视频列表.
到目前为止我在哪里
我知道这是用户以JSON格式"上传"的正确网址:
http://gdata.youtube.com/feeds/api/users/%USERNAME%/uploads?alt=json&v=2
其中USERNAME是频道名称,而不是与用户频道对应的字母/数字字符串(例如,MyChannel而不是hIANSUBhkj_baisu128).
但是,在我的用户名(BenPearlMagic
)上测试时,我会收到一个非常长的JSON列表,其中包含大量似乎无关紧要的数据.
我的代码是这样的:
$.getJSON('http://gdata.youtube.com/feeds/api/users/benpearlmagic/uploads?alt=json', function(data) {
console.log(data);
for(var i=0; i<data.data.items.length; i++) {
console.log(data.data.items[i].title); // title
console.log(data.data.items[i].description); // description
}
});
Run Code Online (Sandbox Code Playgroud)
......但我无法让它发挥作用.
我想做什么
我正在尝试返回列在列之前或等于当前时间的列中具有NULL
或0
值的行TIMESTAMP
.
询问
SELECT *
FROM `drafts`
WHERE `leagueid`="vH8j5R0nlsBYhOUm"
AND (`pick_uid`=NULL OR `pick_uid`='0')
AND `deadline` >= "2015-9-28 13:43:00";
Run Code Online (Sandbox Code Playgroud)
注意:我使用的是字符串值deadline
而不是NOW()
因为用户有不同的时区,因此我使用PHP函数创建时间戳gmdate
以确保请求是UTC.
我期待从这个查询返回的内容
所有行都有id<=709
.
<form action='checks.php' method='POST'>
<div class ="bookinform">
<table>
<tr>
<td>Name of Driver *</td>
<td>
<input type='Text' id="driver_name" name='driver_name' required autocomplete="off" size='7' maxlength='25' style='width:400px;font-family:Century Gothic' value = "">
</td>
</tr>
<tr>
<td> </td>
<td></td>
</tr>
<tr>
<td>Vehicle Reg *</td>
<td>
<input type='Text' id="Vehicle_Reg" name='Vehicle_Reg' required autocomplete="off" size='7' maxlength='15' style='width:400px;font-family:Century Gothic; text-transform:uppercase;' value = "">
</td>
</tr>
<tr>
<td> </td>
<td></td>
</tr>
<tr>
<td valign='top'>Haulier *</td>
<td valign='top'>
<input type='Text' id="query" name='haulier' style='width:400px; font-family:Century Gothic; text-transform:uppercase;' value = "">
<tr>
<td> </td>
<td></td>
</tr>
</table>
<input …
Run Code Online (Sandbox Code Playgroud) 当我使用:
echo gmdate("YmdHis O")
Run Code Online (Sandbox Code Playgroud)
输出是:
20151211091805 +0000
但是现在意大利的错误是 10:00,为什么我的错误?
我连接到数据库index.php
,然后classes.php
使用导入我的文件require_once()
.但是,连接到数据库时,数据库连接未定义.
index.php
$dbh = new PDO("mysql:host=$hostname;dbname=$dbname",$username,$password);
require_once("inc/classes.php");
/* ..... */
if($_POST["form"]=="login"){
//Retrieve values
$e = $_POST["email"];
$p = $_POST["password"];
//Data validation
if(!filter_var($e, FILTER_VALIDATE_EMAIL)||strlen($e)<3) $errors->addError("email", "Please enter a valid email address.");
if(strlen($p)<1) $errors->addError("password", "Please enter a valid password");
$errors->killErrors();
//Log user in
$user = new User($e);
if(!$user->login($p)) $errors->addError("form", "Incorrect username or password.");
$errors->killErrors();
exit("success");
}
Run Code Online (Sandbox Code Playgroud)
inc/classes.php
class User
{
public $id, $email, $data;
public function __construct($e = null){
if(isLoggedIn()){
$stmt = $dbh->prepare("SELECT * …
Run Code Online (Sandbox Code Playgroud)