sheeps Posted April 27, 2012 Share Posted April 27, 2012 I have an array that needs to display all titles and allow for a user to view titles based on the category, title, etc . I tried using the print_r() function but it didn't display the titles in a clean list. The only tutorials I've found utilize sql and i need to complete this without using SQL. $books = array(); array_push($books,array("category" => "Nonfiction","title" => "The Innocent Man","author" => "Grisham","publisher" => "McGraw-Hill","price" => "34.99","isbn" => "5985420166")); array_push($books,array("category" => "Business","title" => "How to Make Money","author" => "Richy","publisher" => "Prentice-Hall","price" => "49.99","isbn" => "8754739342")); array_push($books,array("category" => "Romance","title" => "Twice Kissed","author" => "Jackson","publisher" => "McGraw-Hill","price" => "14.99","isbn" => "5671230987")); Quote Link to comment https://forums.phpfreaks.com/topic/261722-array-help-with-integration-into-e-commerce-catalog/ Share on other sites More sharing options...
sunfighter Posted April 28, 2012 Share Posted April 28, 2012 This is not an easy task. You do need to give more time to what you means by allow for a user to view titles based on the category, title, etc . Is it an alphabetical order of authors and are you committed to doing this in php only? Does view by category mean only Romance novels or alphabetical listing of the categorizes? Anyway the display is probably easier to do with a table. You echo out the table heading and css info. Here is how to get the info out of the array and into a row: <?php $category = $books[1]["category"]; $title = $books[1]["title"]; $author = $books[1]["author"]; $publisher = $books[1]["publisher"]; $price = $books[1]["price"]; $isbn = $books[1]["isbn"]; echo <<<EOD <tr> <td>$category</td> <td>$title</td> <td>$author</td> <td>$publisher</td> <td>$price</td> <td>$isbn</td> </tr> EOD; ?> Quote Link to comment https://forums.phpfreaks.com/topic/261722-array-help-with-integration-into-e-commerce-catalog/#findComment-1341331 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.