iterate through fb:random

Posted by fusion on Stack Overflow See other posts from Stack Overflow or by fusion
Published on 2010-04-19T22:34:21Z Indexed on 2010/04/20 1:13 UTC
Read the original article Hit count: 393

does anyone know how i would fill data from mysql database in fb:random and iterate through it, to pick a random quote?

fb:random

$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 data:

$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>";
}

© Stack Overflow or respective owner

Related posts about mysql

Related posts about facebook-application