Jump to content

Call articles referring to the 'title' column instead of 'id' column


russe11

Recommended Posts

I am trying to make some url friendly at my site. I want to point the query to the "title" column to sort out show the content.
For example:

[b]My current url: [/b]
[color=navy]www.example.com/articles?id=13[/color]

[b]What i want:[/b]
[color=navy]www.example.com/articles?title=i can do this work[/color]; //and then go to the full article...

so when i use the modrewrite, will be something like:

www.example.com/articles/i-can-do-this-work.html

Is any of that makes sensse?Heeeellllllppppp...!!

The code for this:
// create the article list
  $newstext = '<ol>';
  while($row = mysql_fetch_array($result, MYSQL_NUM))
  {
      list($title, $id) = $row;

      $newstext .= "<li><a href=\"$self?id=$id\">$title</a></li>\r\n";
  }

  $newstext .= '</ol>';

  $title = 'My Articles';
} else {
  // get the article info from database
  $query = "SELECT title, newstext FROM news WHERE id=".$_GET['id'];
  $result = mysql_query($query) or die('Error : ' . mysql_error());
  $row = mysql_fetch_array($result, MYSQL_ASSOC);

  $title = $row['title'];
  $newstext = $row['newstext'];
}

mysql_close();
Well, as a final product, this is what i am looking for:

[color=orange]www.example.com/articles/documenttitlehere.html  [/color]

All my efforts has been NOT successful :( pls help.....I know requires a bit of both mod_rewrite and php, but it is just beyond me to figure out how to put all together.

Thank you in advance for the response

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.