Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/270733-i-have-no-idea-how-this-works/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.