I am trying to fetch the column of a table "category" which is linked with table "subcategory" to the table "item".
I am stuck somewhere coz of silly mistake as I'm not sure where i am going wrong.
I am not able to fetch the value of the last "while". I am using category id in subcategory to get a link to category name in category master.
This is the warning i'm getting :
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs**\itemtable.php on line 43
This is line 43 : while($cat_name=mysqli_fetch_array($rowvalcatname));(The second last line)
Here is my code:
<form name='update' action='updateitemtable.php'>
<input type='hidden' name='itemid' value='$item_id'>
<tr><td>$item_id</td>
<td><input type='text' name='itemtablename' value='$row[1]'></td>");
$rowval=mysqli_query($conn, "SELECT subcatname from subcategorymaster WHERE subcatid = $row[2]");
while($row2=mysqli_fetch_array($rowval))
{
echo"<td>$row2[0]</td>";
}
$rowvalcatid=mysqli_query($conn,"SELECT categoryid from subcategorymaster WHERE subcatid=$row[2]");
while($row3=mysqli_fetch_array($rowvalcatid))
{
$rowvalcatname=mysqli_query($conn,"SELECT categoryname from categorymaster WHERE catid=$row3[0]");
while($cat_name=mysqli_fetch_array($rowvalcatname));
echo"<td>$cat_name[0]</td>";
}