我可以用另一种方式标记我的div,以实现我在这里尝试做的事情.我有这个称为错误的主要div,它将显示所有错误消息.问题是,我的表单输入区域和其他指令文本之间需要介入,因为错误消息和文本需要出现在它们下面.当我做一个$('#errors div').empty();所有的指令文本和其他内容被清除,因为它全部在<div id="errors">任何替代方式标记这3个div(eUname,ePwd,eMail)所以它仍然在标签"错误"?
<div id="form">
<div id="errors">
//Input field and other instruction text goes here with its own id
<div id="eUname"></div>
//Input field and other instruction text goes here with its own id
<div id="ePwd"></div>
//Input field and other instruction text goes here with its own id
<div id="eMail"></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
就像是:
<div id="errors" id="eUname" ></div>
Run Code Online (Sandbox Code Playgroud) 我有这个专栏
INT(10) ZEROFILL NOT NULL DEFAULT '0000000000',
但当我插入类似的东西时9100000010,我明白了4294967295
它应该允许10位数,对吗?
怎么做对了?
我正在尝试计算查询返回的行数,我这样做:
$what = 'Norman';
$stmt = $conn->prepare('select names as names from names where names = :what');
$stmt->bindParam('what', $what);
$stmt->execute();
$rows = $stmt->fetchColumn();
echo 'Rows found '.$rows;
$stmt->setFetchMode(PDO::FETCH_ASSOC);
while($row = $stmt->fetch())
{
echo $row['names'] . "<br>";
}
Run Code Online (Sandbox Code Playgroud)
但我始终一无所获。只是空白。这样做的正确方法是什么?
如果有多个elseif,我如何使用简写为php?
我知道如何用一个条件做到这一点,但什么时候有几个?
这是这样的:
if($a == 00){
echo 'Clear';
}elseif ($a == 01) {
echo 'Processing';
} elseif ($a == 10) {
echo 'Marked for delete';
}
Run Code Online (Sandbox Code Playgroud) 我正在使用ajax加载reCaptcha.从其他页面返回的内容中的一行是下面的行,div当我使用时,该行不会被加载到我的行中$(.cap).html(callBack);
这就是这条线
<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=6LcXq-oSAAAAAOgwSIew_xq6xkv1QUxrZbRcMz6n"></script>
这是jQuery不允许的吗?或者我做错了什么?我怎么解决这个问题?如何将jquery从另一个页面返回到我的<div>?
我正在测试的是,很简单:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>No Tile</title>
<script type="text/javascript" src="http://localhost/site/scripts/jQuery.js"></script>
<style type="text/css">
.user {
cursor: pointer;
}
</style>
<script type="text/javascript">
$(document).ready(function() {
//$(".user").live("click",function() {
$(".user").click(function() {
data = "id=Hello"
$.ajax({
type:"GET",
url:"demo.php",
data:data,
dataType:"html",
beforeSend:function(html){
},
success: function(callBack){
$(".cap").html(callBack);
console.log(callBack);
},
error: function(page_data){
},
});
});
});
</script>
</head>
<body>
<div id="container">
<div class="cap">Hello</div>
<span class="user">Add User</span>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是从其他页面返回的行不会被加载到div.
<script type="text/javascript" …
我被卡住了.我需要根据提供的数字创建一个数组,我无法想到任何方法.
需要做的是:如果数字是1需要的数组array("2","3","4","10")
如果数字是2需要的数组array("3","4","10")
如果数字是3需要的数组array("4","10")
如果数字是4需要的数组array("10")
如果数字10不需要数组.
除了有大量的做ifs和elseifs,有没有更优雅的方式来做到这一点?这只是针对这个问题.实际情况更糟.
我的方法:
if ($num == 1) {
$array = array("2","3","4","10");
} elseif ($num == 2) {
$array = array("3","4","10");
} etc.
Run Code Online (Sandbox Code Playgroud) 如何将包含字符串的变量连接到函数名?我尝试了所有方法,但没有一个适合我.
$mode = 'Remove';
friend.$mode.($mode);
function friendRemove() {
}
Run Code Online (Sandbox Code Playgroud) 在php中我需要检查5个变量是否是相同的值,然后继续.
而不是做
if($a == 'logged' && $b == 'logged' && $c == 'logged' && $d == 'logged' && $e == 'logged')
{
// Code to run here
}
Run Code Online (Sandbox Code Playgroud)
有不同的方法吗?喜欢:
if($a,$b,$c,$d == 'logged')
Run Code Online (Sandbox Code Playgroud)
这样的事可能......?
我正在尝试在下面之间获取函数输出文本.但它总是排在最前面.知道怎么设置这个吗?它应该是Apple Pie,Ball,Cat,Doll,Elephant,但玩偶总是最重要的.
function inBetween()
{
echo 'Doll <br>';
}
$testP = 'Apple Pie <br>';
$testP .='Ball <br>';
$testP .='Cat <br>';
inBetween();
$testP .='Elephant';
echo $testP;
Run Code Online (Sandbox Code Playgroud) 我怎么能算带班格的数量item是有阶级的DIV中outer-1?这里的结果应该是 7。
我尝试了这个和它的其他几个失败的变体。
alert( $(".outer-1").$(".item").length );
Run Code Online (Sandbox Code Playgroud)
这给了我12页面上的所有 div。
alert( $(".item").length );
如何仅指定outer-1div?
分区
<div class="outer-1">
<div class="item">a</div>
<div class="item">b</div>
<div class="item">c</div>
<div class="item">d</div>
<div class="item">e</div>
<div class="item">f</div>
<div class="item">g</div>
</div>
<div class="outer-2">
<div class="item">a</div>
<div class="item">b</div>
<div class="item">c</div>
<div class="item">d</div>
<div class="item">e</div>
</div>
Run Code Online (Sandbox Code Playgroud) 我如何将<i> </i>标签包裹在下面的This is line one!, This is line two!,周围,结果是:This is line three!$thisStr
`<i>This is line one!</i>`
`<i>This is line two!</i>`
`<i>This is line three!</i>`
Run Code Online (Sandbox Code Playgroud)
我所做的只是在::零件周围贴上标签。我无法让它后退和前进并包裹标签。
$thisStr = 'This is line one! :: This is line two! :: This is line three!';
echo preg_replace("/(::)/i", "<i>$1</i>", $thisStr);
我试图让一个开关返回真或假,但我似乎在某个地方失败了.我一直都是假的.我完全迷失了.这实际上应该有效.我怎么做到这一点?
if (validNum(1))
{echo 'Ok';}else{echo 'Fail';}
function validNum($x)
{
switch ($x)
{
case 1:
echo "Number 1";
break;
return true;
case 2:
echo "Number 2";
break;
return true;
case 3:
echo "Number 3";
break;
return true;
default:
echo "No number between 1 and 3";
return false;
}
}
Run Code Online (Sandbox Code Playgroud)