第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

這前面的代碼,$arr不是一個空數(shù)組嗎,后面還怎么預(yù)處理?

header(...);

require_once('connect.php');

require_once('comment.class.php');

$arr=array(); ? ? ? ? //這里這個$arr就是空數(shù)組了

$res=Comment::validate($arr); ? ? ? //空數(shù)組進行FILTER過濾有意義嗎

這下面的預(yù)處理操作,$arr還是空數(shù)組,這些怎么回事,


順帶一提,AJAX也不懂,路徑上沒有

正在回答

4 回答

把所有的代碼 都貼出來 ?說說你要實現(xiàn)什么功能,你可以先進行判斷在處理啊

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

堅持MyDream 提問者

上面的問題不提了,下面貼代碼,我順便問一下, foreach()是不是在submit點擊提交之后重新執(zhí)行一遍,也就是說,submit點擊之后,之前foreach()循環(huán)出來的幾個output語句全部消失,重新遍歷數(shù)據(jù)庫里的數(shù)據(jù)再一一output出來
2016-12-25 回復(fù) 有任何疑惑可以回復(fù)我~
#2

堅持MyDream 提問者

還是說submit點擊之后,通過comments.js腳本頁面代碼,所以在foreach()之后再output一次,
2016-12-25 回復(fù) 有任何疑惑可以回復(fù)我~
#3

堅持MyDream 提問者

我懂了,載入頁面時,foreach語句遍歷數(shù)據(jù)庫,把所有數(shù)據(jù)都o(jì)utput出來。 但是又有個問題,點擊submit之后,發(fā)布的評論信息 顯示在foreach遍歷出來的評論信息下面,是什么時候設(shè)置的,為什么點擊submit之后 發(fā)布的評論信息 不是顯示在網(wǎng)頁最下邊??
2016-12-25 回復(fù) 有任何疑惑可以回復(fù)我~
#4

堅持MyDream 提問者

非常感謝!
2016-12-27 回復(fù) 有任何疑惑可以回復(fù)我~
查看1條回復(fù)

//這是output方法

public function output(){

if($this->data['url']){

$link_start="<a href='".$this->data['url']."' target='_blank'>";

$link_end="</a>";

}else {

? ?$link_start='';

? ?$link_end='';

}

$dateStr=date("Y年m月d日 H:i:s",$this->data['pubTime']);

$res=<<<EOF

<div class='comment'>

<div class='face'>

{$link_start}

<img width='50' height='50' src="img/{$this->data['face']}.jpg" alt="" />

{$link_end}

</div>

<div class='username'>

{$link_start}

{$this->data['username']}

{$link_end}

</div>

<div class='date' title='發(fā)布于{$dateStr}'>

{$dateStr}

</div>

<p>{$this->data['content']}</p>

</div>

EOF;

return $res;

}


0 回復(fù) 有任何疑惑可以回復(fù)我~

//這個是index.php頁面

<?php?

require_once('connect.php');

require_once('comment.class.php');

$sql="SELECT username,email,url,face,content,pubTime FROM comments";

$mysqli_result=$mysqli->query($sql);

if($mysqli_result&& $mysqli_result->num_rows>0){

while($row=$mysqli_result->fetch_assoc()){

$comments[]=new Comment($row); ? ? ? ? ?//創(chuàng)建一個對象,將$row作為參數(shù)寫入構(gòu)造函數(shù)

}

}

?>

<!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" xml:lang="en">

<head>

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />

<title>Document</title>

<link rel="stylesheet" type="text/css" href="style/style.css" />

</head>

<body>

<h1>慕課網(wǎng)評論系統(tǒng)</h1>

<div id='main'>

<?php?

foreach($comments as $val){

echo $val->output();

}

?>

<div id='addCommentContainer'>

<form id="addCommentForm" method="post" action="comment.class.php">

? ? ?<div>

? ? ? ? ?<label for="username">昵稱</label>

? ? ? ? ?<input type="text" name="username" id="username" required='required' placeholder='請輸入您的昵稱'/>

? ? ? ? ? ??

? ? ? ? ? ? <label for="face">頭像</label>

? ? ? ? ? ? <div id='face'>

<input type="radio" name="face" checked='checked' value="1" /><img src="img/1.jpg" alt="" width='50' height='50' />&nbsp;&nbsp;&nbsp;

<input type="radio" name="face" ?value="2" /><img src="img/2.jpg" alt="" width='50' height='50' />&nbsp;&nbsp;&nbsp;

<input type="radio" name="face" ?value="3" /><img src="img/3.jpg" alt="" width='50' height='50' />&nbsp;&nbsp;&nbsp;

<input type="radio" name="face" ?value="4" /><img src="img/4.jpg" alt="" width='50' height='50' />&nbsp;&nbsp;&nbsp;

<input type="radio" name="face" ?value="5" /><img src="img/5.jpg" alt="" width='50' height='50' />&nbsp;&nbsp;&nbsp;

? ? ? ? ? ? </div>

? ? ? ? ? ? <label for="email">郵箱</label>

? ? ? ? ? ? <input type="email" name="email" id="email" required='required' placeholder='請輸入合法郵箱'/>

? ? ? ? ? ??

? ? ? ? ? ? <label for="url">個人博客</label>

? ? ? ? ? ? <input type="url" name="url" id="url" />

? ? ? ? ? ??

? ? ? ? ? ? <label for="content">評論內(nèi)容</label>

? ? ? ? ? ? <textarea name="content" id="content" cols="20" rows="5" required='required' placeholder='請輸入您的評論...'></textarea>

? ? ? ? ? ? <input type="submit" id="submit" value="發(fā)布評論" />

? ? ? ? </div>

? ? </form>

</div>

</div>

<script type="text/javascript" src="script/jquery.min.js"></script>

<script type="text/javascript" src="script/comment.js"></script>

</body>

</html>


0 回復(fù) 有任何疑惑可以回復(fù)我~

$(document).ready(function(){

//這個是comments.js頁面

//此標(biāo)志用于標(biāo)志是否提交,防止多次提交

var flag=false;

//監(jiān)測是否提交

$('#addCommentForm').submit(function(e){

//阻止表單的自動提交

? e.preventDefault();

if(flag) return false;

flag = true;

$('#submit').val('發(fā)布...');

$('span.error').remove();

//通過Ajax發(fā)送數(shù)據(jù)

$.post('doAction.php',$(this).serialize(),function(msg){


flag = false;

$('#submit').val('發(fā)布評論');

if(msg.status){

$(msg.html).hide().insertBefore('#addCommentContainer').slideDown();

$('#content').val('');

}

else {

$.each(msg.errors,function(k,v){

$('label[for='+k+']').append('<span class="error">'+v+'</span>');

});

}

},'json');

});

});




0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

這前面的代碼,$arr不是一個空數(shù)組嗎,后面還怎么預(yù)處理?

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號