I have a database that has a list of items in it that when combined make another item. (or thats the theory) but im having issues getting it to display the information. The loop runs once, then bails and does not run the rest of the code (to complete the table).
The items required part shows with the item names, but the item given and make link do not show. If i take the loop out the table processes fine.
<?php
include_once('globals.php');
echo '<h2>Workshop</h2>';
echo '<table border="0" width="95%" cellspacing="1" cellpadding="0" class="table">
<tr style="background: gray; ">
<th>Recipe ID</th>
<th>Items Required</th>
<th>Item Given</th>
<th>Make</th>
</tr>
<tr>';
$fetch = mysql_query("SELECT * FROM workshop") or die(mysql_error());
while($recipe = mysql_fetch_assoc($fetch))
{
$sele = mysql_fetch_assoc($db->query("SELECT inv_id FROM inventory WHERE inv_userid = '{$ir['userid']}'")) or die(mysql_error());
$itemr = mysql_fetch_assoc($db->query("SELECT itmid, itmname FROM items WHERE itmid = '{$recipe['reciperecieved']}'")) or die(mysql_error());
// }
echo "<td> {$recipe['recipeid']} </td>";
echo "<td> ";
$items=explode(",","{$recipe['reciperequired']}");
$ingredients=count($items);
for ($i = 0; $i <= $ingredients; $i++)
{
$itemname = mysql_fetch_assoc($db->query("SELECT itmid, itmname FROM items WHERE itmid = '{$items[$i]}'")) or die(mysql_error());
echo "{$itemname['itmname']}
";
}
echo "</td>";
echo "<td> {$itemr['itmname']} </td>";
echo "<td>Make</td></tr>";
}
echo "</table>";
$h->endpage();
?>
Above is my code, im new to both PHP and mySQL (I learned in old skool pascal!) so sorry if it looks bad!. I intend ot make the full mode free on here once its finished.
Ill give + to anyone that can help!
Thanks in advance.