I've been trying to do a multidimensional (?) array but am pretty stuck.
Basically, the crux of the problem is when I have 'missing' records - and I just don't know how to solve that problem. Let me explain.
I have a Table of books (these are not literal values)
Library_id | Book_id | Book_Title | Count
1 | id_14 | my abc | 5
3 | id_6 | my abc | 7
4 | id_15 | my abc | 3
There are 4 libraries, but not all book names are kept in each library. However, when I do a query, I want every library to be listed and empty records to be listed with specified values.
Output
Details for book name is: my abc
id_14 Absent id_6 id_15
5 0 7 3
I have with some help, managed to create the output I want using arrays... but it works only if the $book_title is present for every $lib_id. But when there are empty records, my output file screws up (I am outputing data to a graph and not a table). So I thought I might need to do some sort of association to get the output all in the right order and indicate absence if there is no data to solve the problem.
My search query is simple:
Search query:
Sql โselect * from Books where $book_title=โmy abcโโ;
Define (Book_id as $book_id);
Define (Library_id as $lib_id);
Define (Count as $count);
- I assume that I should create a Library ID array.
$Library_array[]=array('1', '2', '3', '4');
From here on ... I am totally lost as to how to create the associations:
Somehow I need to match the $lib_id with the $Library_array[] values. How?
If there is no match to a particular Library_array[] value, then I want to set the $book_id to "Absent" and the $count to "0".
Hopefully someone might be able to help me out? ๐