First off let me say thanks for the wealth of information found on this site, it has gotten me miles beyond where I was just a short time ago.
What I am trying to do is 'display' the value of a field as its reference. ( I hope I am saying this right) This particular field (items.type) relates to the key of another table (item_type.id), I am trying to 'display' the item_type.type related to that id.
Heres a snipit of the code as it relates to this.
$output .= "<script type=\"text/javascript\">
answerbox.btn_ok='{$lang_global['yes_low']}';
answerbox.btn_cancel='{$lang_global['no']}';
var question = '{$lang_global['are_you_sure']}';
var del_items = 'item_entry.php?action=del_items&order_by=$order_by&start=$start&dir=$dir&id=';
</script>
<table class=\"lined\">
<tr>
<th width=\"5%\">{$lang_global['delete_short']}</th>
<th width=\"5%\"><a href=\"item_entry.php?order_by=id&start=$start&dir=$dir\"".($order_by=='id' ? " class=\"$order_dir\"" : "").">{$lang_itemsum['id']}</a></th>
<th width=\"10%\"><a href=\"item_entry.php?order_by=item_id&start=$start&dir=$dir\"".($order_by=='item_id' ? " class=\"$order_dir\"" : "").">{$lang_itemsum['item_id']}</a></th>
<th width=\"29%\"><a href=\"item_entry.php?order_by=name&start=$start&dir=$dir\"".($order_by=='name' ? " class=\"$order_dir\"" : "").">{$lang_itemsum['name']}</a></th>
<th width=\"7%\"><a href=\"item_entry.php?order_by=type&start=$start&dir=$dir\"".($order_by=='type' ? " class=\"$order_dir\"" : "").">{$lang_itemsum['type']}</a></th>
<th width=\"7%\"><a href=\"item_entry.php?order_by=vend&start=$start&dir=$dir\"".($order_by=='vend' ? " class=\"$order_dir\"" : "").">{$lang_itemsum['vend']}</a></th>
<th width=\"7%\"><a href=\"item_entry.php?order_by=req&start=$start&dir=$dir\"".($order_by=='req' ? " class=\"$order_dir\"" : "").">{$lang_itemsum['req']}</a></th>
<th width=\"7%\"><a href=\"item_entry.php?order_by=ord_allo&start=$start&dir=$dir\"".($order_by=='ord_allo' ? " class=\"$order_dir\"" : "").">{$lang_itemsum['ord_allo']}</a></th>
<th width=\"7%\"><a href=\"item_entry.php?order_by=on_hand&start=$start&dir=$dir\"".($order_by=='on_hand' ? " class=\"$order_dir\"" : "").">{$lang_itemsum['on_hand']}</a></th>
<th width=\"7%\"><a href=\"item_entry.php?order_by=allo&start=$start&dir=$dir\"".($order_by=='allo' ? " class=\"$order_dir\"" : "").">{$lang_itemsum['allo']}</a></th>
<th width=\"7%\"><a href=\"item_entry.php?order_by=avail&start=$start&dir=$dir\"".($order_by=='avail' ? " class=\"$order_dir\"" : "").">{$lang_itemsum['avail']}</a></th>
</tr>";
while ($data = $sql->fetch_row($query) & $query_t = $sql->query("SELECT `type` FROM `item_type` WHERE `id` = $data[3]")){
//$query_t = $sql->query("SELECT `type` FROM `item_type` WHERE `id` = $data[3]");
$output .= "<tr>
<td><img src=\"img/aff_cross.png\" alt=\"\" onclick=\"answerBox('{$lang_global['delete']}: <font color=white>{$data[1]}</font> <br /> ' + question, del_items + $data[0]);\" style=\"cursor:pointer;\" /></td>
<td>$data[0]</td>
<td>$data[1]</td>
<td><a href=\"item_entry.php?action=edit_items&id=$data[0]\">$data[2]</a></td>
<td>$query_t</td>
<td>$data[4]</td>
<td>$data[5]</td>
<td>$data[6]</td>
<td>$data[7]</td>
<td>$data[8]</td>
<td>$data[9]</td>
</tr>";
}
$output .= "<tr><td colspan=\"8\" class=\"hidden\" align=\"right\">{$lang_itemsum['tot_items']} : $all_record</td></tr>
</table></center>";
$sql->close();
}
everything works great if I just display $data[3] but that doesnt really show me the "Type", just an integer.
Ive tried various other things such as:
<td>$query_t[$data[3]]</td>
$query_t = $sql->query("SELECT type, id FROM item_type AS type");
and various combinations of things.
If someone could point me in the direction of some documentation about this kind of thing I would greatly appreciate it. Ive searched around here and the PHP manual quite a bit but I guess I dont really know enough to even know "what" to look for. Ive tried looking for various things like passing variables as reference on fetch_assoc() but either I didnt look deep enough or thats not really what Im trying to do.
Again, thanks for any assistance you can provide.