I have pulled my hair out on what seems to simple but I can't get it to work.
I have one function that pulls data from mysql into an array and another function that displays it. It works with one variable at a time but I can't seem to pull other columns into the array and get it to diplay. Please help. Here is the code.
function get_items($username)
{
//extract from the database all the items this user has stored
if (!($conn = db_connect()))
return false;
$result = mysql_query( "select *
from user_info
where username = '$username'");
if (!$result)
return false;
//create an array of the items
$item_array = array();
for ($count = 1; $row = mysql_fetch_row ($result); ++$count)
{
$item_array[$count] = $row[3];
}
return $item_array;
};
This function displays it....
function display_user_items($item_array)
{
//display the items
echo "Item# Items";
if (is_array($item_array) && count($item_array)>0)
{
foreach ($item_array as $item_title)
{
// remember to call htmlspecialchars() when we are displaying user data
echo "<tr bgcolor=$color><td>".htmlspecialchars($sku)."</td>";
echo "<td>".htmlspecialchars($item_title)."</td>";
echo "<td><input type=checkbox name=\"del_me[]\"
value=\"$item_title\"></td>";
echo "</tr>";
}
}
else
echo "<tr><td>No items in inventory</td></tr>";
?>
Sorry for the long message.