2013-02-20 58 views
0

在這種情況下是否有任何錯誤?結果沒有顯示。也許我得到的語法錯了?從sql查詢不顯示變量結果

// fetch the latest tweet 
$lastTweet = ''; 
$q2 = "SELECT tweet FROM timel ORDER BY id DESC LIMIT 1"; 
list($lastTweet) = $conn->get_results($q2); 



if(!$lastTweet){ 
$lastTweet = "You don't have any tweets yet!"; 
} 
var_dump($lastTweet); 

,這對HTML正文:

<span class="latest"><strong>Latest: </strong><span id="lastTweet"><?.=$lastTweet?></span></span> 
+0

<?。= $ lastTweet this dot? – 2013-02-20 21:11:00

+0

By <?。=你的意思是<?=? – DiMono 2013-02-20 21:11:01

+0

在'<?。= $ lastTweet?>'中,在'?'和'='之間有'.'。去掉它。 – 2013-02-20 21:14:33

回答

1

使用此:

<span class="latest"><strong>Latest: </strong><span id="lastTweet"> 
<?php echo $lastTweet; ?></span> </span> 

Saludos;)

+0

okidoki。這個伎倆!嗯。所以我仍然必須使用$ echo功能。非常感謝Robert Rozas。並感謝大家的回覆。 :) – asleighna 2013-02-20 21:26:43

2

如果你改變了你的第一線,

$lastTweet = array(); 

而且你的第三個行

$lastTweet = $conn->get_results($q2); 

然後,你將能夠使用

<?php var_dump($lastTweet); ?> 

但在你的情況lastTweet包含文本字符串,因此你需要使用echo打印出來的內容。

<?php echo $lastTweet ?> 

注:我不知道你的項目的細節,但我猜你需要也得到了日期,也許鳴叫的ID和user_ID的,如果是那樣的話,你可能要使lastTweet成爲一個空數組()