It works it's just that it seems so uneccessary.
The main problem is with db_result_to_arry
I'm coming from a page that passes $catid as a parameter or variable. and creating a list of books.
The db_result-to_array creates an array of arrays of arrays which can be simplified.
I appreciate any help I've been working on this all day
heres the code.
function get_books($catid)
{
// query database for the books in a category
if (!$catid || $catid=="")
return false;
$conn = db_connect();
$query = "select * from books where catid='$catid'";
$result = @mysql_query($query);
if (!$result)
return false;
$num_books = @mysql_num_rows($result);
if ($num_books ==0)
return false;
$result = db_result_to_array($result);
return $result;
}
function db_result_to_array($result)
{
$res_array = array();
for ($count=0; $row = @mysql_fetch_array($result); $count++)
$res_array[$count] = $row;
return $res_array;
function display_books($book_array)
{
//display all books in the array passed in
if (!is_array($book_array))
{
echo "<br>No books currently available in this category<br>";
}
else
{
//create table
echo "<table width = \"100%\" border = 0>";
//create a table row for each book
foreach ($book_array as $row)
{
$url = "show_book.php?isbn=".($row["isbn"]);
echo "<tr><td>";
if (@file_exists("images/".$row["isbn"].".jpg"))
{
$title = "<img src=\"images/".($row["isbn"]).".jpg\" border=0>";
do_html_url($url, $title);
}
else
{
echo " ";
}
echo "</td><td>";
$title = $row["title"]." by ".$row["author"];
do_html_url($url, $title);
echo "</td></tr>";
}
echo "</table>";
}
echo "<hr>";
}
Thank You