iterate through fb:random
- by fusion
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>";
}