Hello everybody,
I have created a form which allows users to save weblinks in database. Now I want to display these weblinks. I will explain this by following example.
Imagine I have got three categories.

Administration
Sports
Culture

when user clicks on "Administration" it should display all links related to this category.

Could anybody tell me what is the simplest way to do this please??

Thanks a lot.

Comments

znation’s picture

It sounds to me like the clean way to do this in Drupal is to use the taxonomy module to create a vocabulary for categories, then add terms like "Administration" and "Sports" to that vocabulary. Create a node type (using cck, or a custom module, etc.) to hold these links, and let users upload them using the node/add form.

However, if you already have the links in the database, you'll probably just want to create a php page to display them. Add a new page, and put code (somewhat) like this inside PHP brackets (substitute database terms and output method as appropriate):

$category = $_GET['category'];
$query = "SELECT link FROM {links} WHERE category='%s'";
$result = db_query($query, $category);
while ($obj = db_fetch_object($result)) {
  print $obj->link;
}

And then link to your page with http://site/node/123/?category=Administration. (Insert category name as appropriate).

scrypter’s picture

why not use the weblinks module?

www.scryptik.com - Javascript editor with syntax error checking
www.purpleoar.co.nz - Web development, Drupal consultancy

www.purpleoar.co.nz/scryptik - Javascript editor with syntax error checking
www.purpleoar.co.nz - Web development, Drupal consultancy