我有表post:int post_id, varchar title, text content
和表comment:int comment_id, int post_id, varchar content其中post_id是外键引用表的帖子.
如何通过评论计数获得每个帖子顺序的post_id和评论总和.谢谢.
HTML:
<li class="comment">
<div class="p_comm">
<div class="avatar"><img src="/img/1.jpg"></div>
<div class="c_auth">author<a class="del" title="delete it!" rel="19">x</a></div>
<div class="c_cont w">what ever</div>
<div class="c_time">12-23 13:22:15</div>
</div>
</li>
Run Code Online (Sandbox Code Playgroud)
我想找到相对于<a>本节中的父李.我找不到这样做的功能.我试过prev(),parentsUntil()他们都不能做到这一点.目前我必须使用$(this).parent().parent().parent()到达<li>.是否有<li>直接查找父母的功能?
我试过了
str_replace(array("\r\n", "\r", "\n", "\t"), ' ', $text);
Run Code Online (Sandbox Code Playgroud)
它可能会删除新行,但仍有一些标签,如下所示.什么是preblem?
Metal Machine Music, Part I<br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> Metal Machine Music, Part II<br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> Metal Machine Music, Part III<br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br />
Run Code Online (Sandbox Code Playgroud) 我使用jquery来请求数据,然后将它们填充到id为"mresholder"的表中,它在webkit和ff中工作,但它在IE中不能很好地工作.它将追加这些数据</table>.
如何解决这个问题或者替代方法是什么?
for(i=0;i<length;i++)
{
song=data.results[i];
o=$('#mresholder').html();
$('#mresholder').html(o+='<tr sid='+song.song_id+' aid='+song.album_id+'><td class="sname">'+song.song_name+'</td><td class="sartist">'+song.artist_name+'</td><td class="salbum">'+song.album_name+'</td></tr>');
};
Run Code Online (Sandbox Code Playgroud) 这是我的jquery代码.如果你看不到它的任何缺陷,请继续在http://jsfiddle.net/J4ZgB/3/看看JSfiddle .谢谢.
$(function(){
$("#a").click(function(){
var s=$('#p_content').css("font-size");
s+=4;
$('#p_content').css("font-size",s+"px");
})
})
Run Code Online (Sandbox Code Playgroud) 为了保存数据流,我使用这些行将文本换成带有锚点的模式,代码执行成功,但为什么看起来生成的锚点不可点击?
$(function(){
$(".block span").each(function(){
$(this).wrapInner("<a></a>")
$(this).find("a").attr("herf","/tag/"+encodeURIComponent($(this).html()));
})
})
Run Code Online (Sandbox Code Playgroud)
你也可以在这里看到jsfiddle:http://jsfiddle.net/vftMe/
我的代码中是否有任何错误?或者它只是浏览器的限制?有什么替代方法可以做到这一点?
代码在其他浏览器中完美运行,但在IE7中则不行.IE7中的问题是,当选择第一级时,列表的第二级(ul .opt_1)将不会显示.这是HTML部分:
<input type="button" id="topic" value="please select a topic"/>
<div class="c"></div>
<ul id="opt_0">
<li class="opt_0">finance</li>
<ul class="opt_1">
<li>business</li>
<li>stock</li>
<li>company</li>
<li>startup</li>
</ul>
<li class="opt_0">IT</li>
<ul class="opt_1">
<li>internet</li>
<li>code</li>
<li>hardware</li>
</ul>
</ul>
<input type="hidden" name="topic"/>
Run Code Online (Sandbox Code Playgroud)
和JS部分:
$(function(){
$("#topic").click(function(){
$("#opt_0").slideDown();
})
$(".opt_0").click(function(){
$(".opt_0").removeClass("selected");
$(this).addClass("selected");
$(".opt_1").hide();
$(this).next(".opt_1").show();
})
$(".opt_1 li").click(function(){
$("#opt_0").slideUp();
$("#topic").val($(".selected").html()+">>"+$(this).html());
$("input[name=\"topic\"]").val($(".selected").html()+";"+$(this).html());
})
})
Run Code Online (Sandbox Code Playgroud)
你可以在这里看到JS小提琴:http://jsfiddle.net/lornechang/4BmPb/
如何使它与IE7兼容?谢谢.
我有一堆从客户端代码传递的环境变量,如果没有设置它们,我需要为它们设置默认值。
除了用大量的方法一一测试它们之外if ...; then ... fi,还有一种干净的方法可以做到这一点吗?
我是PHP OOP的新手,我认为public $var并且__construct()完全相同.有什么不同?我应该使用哪一个?