Shirasu Posted November 15, 2012 Share Posted November 15, 2012 Hi, Som I'm currently making a website using Joomla. One of the pages is supposed to list restaurants ordered by area, and under by name. There will be several of these pages, so different cities are involved too. So since I've helped on a site that had a similar thing, I thought I could modify that php code and add a similar database table. The table is called _restaurant, and the needed columns are 'city', 'area', 'restaurant' and 'link'. Basicly how I want it to look on the page for "TheCity": Area1 Restaurant sorted Area2 by name The name of the restaurant is what u see on the list, but they are actually links to their website, taken from the 'link' column. I really don't have any PHP experience at all, but I hope it's ok for me to ask for help anyway. When I edited the code I got; <?php $db =& JFactory::getDBO(); $query = "SELECT * FROM #__restaurant WHERE city='TheCity' ORDER BY 'area', 'restaurant'"; $db->setQuery($query); $db->loadAssoc(); if($value == null) $value = $citysort; $reses = $db->loadAssocList(); $last = ""; foreach ($reses as $row) { $text = "<strong>{$row['area']}</strong><br />"; if($value == $citysort){ if($row['area'] != $last){ echo "<h4><a name=\"{$row['area']}\" city=\"\"></a>{$row['area']}</h4>"; $last = $row['area']; } $text = ""; } echo "<p class=\"contentpane\">" . $text . "<a target='_blank' href=\"{$row['link']}\">{$row['restaurant']}<br /></a></p>"; } ?> This gave me the list, but it would always type out the 'area' eventhough it was already listed, and they did not sort either. I really hope someone is willing to help someone who don't really have any experience. Quote Link to comment Share on other sites More sharing options...
Beeeeney Posted November 15, 2012 Share Posted November 15, 2012 At least go learn the basics of PHP. Quote Link to comment 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.