I am using smarty php template and sql server
I have the following tables :
table 1 (anime_pages) : contains data
table 2 (anime_genres) : contains categories
table 3 (genres_pages) : contains relationship between data and category
I am trying to show 3 random categories with 10 data results from that category.
I have the following php code right now :
$randomcsql = $db->query("SELECT * FROM anime_genres ORDER BY RAND() LIMIT 3");
while($ft5 = $db->fetch_array($randomcsql))
{
$randomcats[] = $ft5;
}
$smarty->assign('randomcats' , $randomcats);
$db->free_result($randomcsql);
$animecatssql = $db->query("SELECT * FROM anime_pages JOIN genres_pages ON anime_pages.id = genres_pages.genre_id WHERE genres_pages.genre_id = (".$ft5['id'].") LIMIT 10 ");
while($ft6 = $db->fetch_array($animecatssql))
{
$animecats[] = $ft6;
}
$smarty->assign('animecats' , $animecats);
$db->free_result($animecatssql);
the problem is with (".$ft5['id'].") it is not giving me any result and If I replaced it with a number … I will get a duplicated result (every data is duplicated twice)
How can I solve the problem ?
Is there a better code to use ?
I am trying to something like this : http://img37.imageshack.us/img37/5024/unled1qk.png
I solved it by showing on random result instead of three