hii, this code works.., i want to take category name in category tbl by using category_code in book tbl..
i use simple query :
$query="SELECT name_category FROM categori WHERE code_kategory='{$rows->code_category}'";
but this query run in my loop, is there any other way to get the category_name ? (i mean run the query outside the loop but still get the category name for each book i displayed by using :$rows=$result->fetch_object() in loop)
// ...some codes and queries
$numrows=$result->num_rows;
for ($i=0;$i<$numrows;$i++)
{
$rows=$result->fetch_object();
$query="SELECT name_kategori FROM category WHERE code_category='{$rows->code_category}'";
$result2=$db->query($query);
if (!$result2)
{
echo "wrong query";
exit();
}
$cat=$result2->fetch_object();
echo "<tr>";
echo "<td>$rows->code_book </td>";
echo "<td>$rows->title </td>";
echo "<td>$cat->name_category</td>";
echo "</tr>";
}
thanks for any helps, oh and one more :p how bout the way i display books...?
is it good already or it will cause hard process by mysql or php?