0
<?php
//wall ===================================================
if($_POST['submit'] == "submit"){
// connect to the database
include("dbinfo.inc.php");
$client_id = $_POST['client_id'];
echo $client_id;
$query="select * from messages where client_id='$client_id'";
$result = $mysqli->query($query);
$row = $result->fetch_assoc();
while ($row = $result->fetch_object())
{
$id = $row->msg_id;
$mes = $row->message;
$mes = nl2br($mes);
$cdate = $row->date_post;
$msg ="{$mes} <br> . {$cdate}";
//wall ===================================================
?>
<li class="bar<?php echo $id; ?>">
<div align="left" class="post_box">
<span style="padding:10px"><?php echo $msg; ?> </span>
<span class="delete_button"><a href="#" id="<?php echo $id; ?>" class="delete_update">X</a></span>
<span class='feed_link'><a href="#" class="comment" id="<?php echo $id; ?>">comment</a></span>
</div>
<div id='expand_box'>
<div id='expand_url'></div>
</div>
<div id="fullbox" class="fullbox<?php echo $id; ?>">
<div id="commentload<?php echo $id; ?>" >
</div>
<div class="comment_box" id="c<?php echo $id; ?>">
<form method="post" action="" name="<?php echo $id; ?>">
<textarea class="text_area" name="comment_value" id="textarea<?php echo $id; ?>">
</textarea><br />
<input type="submit" value=" Comment " class="comment_submit" id="<?php echo $id; ?>"/>
</form>
</div>
</div>
</li>
<?php }
//wall ===================================================
$mysqli->close();
}
//wall ===================================================
?>
我的腳本應該輸出等同於用戶輸入的所有數據。腳本在數據庫輸出上跳過1個數據
EX輸入CLIENT_ID 「2」
查詢:
msg_id message date_sent client_id
1 a 1/1/1 1
2 b 2/2/2 1
3 c 3/3/3 1
4 d 1/2/3 1
5 e 2/2/2 2
7 e 2/2/2 2
8 g 2/2/2 2
9 f 8/8/8 3
它將只顯示
7 e 2/2/2 2
8 g 2/2/2 2
並跳過非常第一其中一個是
5 e 2/2/2 2
如果我輸入client_id「 3"
不會有輸出,但它應該顯示:
9 f 8/8/8 3
請你檢查我的劇本,看看我在做什麼錯在這裏?
我應該刪除那部分? – telexper
是的,將第一個作業刪除到'$ row'。 –
太棒了!感謝工作正常:) 5分鐘,直到我接受你的答案 – telexper