2010-04-19 4 views
1

누구나 내가 어떻게 fb : mysql 데이터베이스에서 데이터를 채울 것이라고 알고 임의의 견적을 선택하고 그것을 통해 반복?fb를 통해 반복 : 임의

FB : 임의

$facebook->api_client->fbml_setRefHandle('quotes', 
'<fb:random> 
<fb:random-option>Quote 1</fb:random-option> 
<fb:random-option>Quote 2</fb:random-option> 
</fb:random>'); 

MySQL의 데이터 : 일반적으로

$rowcount = mysql_result($result, 0, 0); 
$rand = rand(0,$rowcount-1); 

$result = mysql_query("SELECT cQuotes, vAuthor, cArabic, vReference FROM thquotes LIMIT $rand, 1", $conn) 
    or die ('Error: '.mysql_error()); 


$row = mysql_fetch_array($result, MYSQL_ASSOC); 
if (!$row) { 
    echo "Empty"; 
} 
else{ 

$fb_box = "<p>" . h($row['cArabic']) . "</p>"; 
$fb_box .= "<p>" . h($row['cQuotes']) . "</p>"; 
$fb_box .= "<p>" . h($row['vAuthor']) . "</p>"; 
$fb_box .= "<p>" . h($row['vReference']) . "</p>"; 
} 

답변

0

, 나는 임의의 견적 또는 다른 데이터를 급지 할 때 내가 뭘 내가 id 모두 선택이다 s를 배열에 넣은 다음 배열에서 임의로 선택하십시오. 그런 다음 id을 사용하여 원하는 것을 골라냅니다. 예를 들어

: 난 이미하고 있어요

$sql = "SELECT `id` FROM `quotes`;"; 
$result = mysql_query($sql); 
$count = mysql_num_rows($result); 

$id = rand(1, $count); 

$sql = "SELECT `text`,`author` FROM `quotes` WHERE `id`='$id' LIMIT 1;"; 
$result = mysql_query($sql); 
$quote = mysql_fetch_assoc($result); 
+0

. 하지만 난 fb : random 태그를 사용하여 이것을 어떻게 할 것인지 알고 싶습니다. – input