Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6593513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:41:30+00:00 2026-05-25T17:41:30+00:00

I am having this website http://www.finalyearondesk.com . My blogs post link are set like

  • 0

I am having this website http://www.finalyearondesk.com . My blogs post link are set like this.. http://www.finalyearondesk.com/index.php?id=28 . I want it to set like this … finalyearondesk.com/2011/09/22/how-to-recover-ubuntu-after-it-is-crashed/ .

I am using the following function to get these posts…

function get_content($id = '') {

    if($id != ""):
        $id = mysql_real_escape_string($id);
        $sql = "SELECT * from cms_content WHERE id = '$id'";
        $return = '<p><a href="http://www.finalyearondesk.com/">Go back to Home page</a></p>';
        echo $return;

    else:
        $sql = "select * from cms_content ORDER BY id DESC";

    endif;

    $res = mysql_query($sql) or die(mysql_error());

    if(mysql_num_rows($res) != 0):

        while($row = mysql_fetch_assoc($res)) {
            echo '<h1><a href="index.php?id=' . $row['id'] . '">' . $row['title'] . '</a></h1>';
            echo '<p>' . "By: " . '<font color="orange">' . $row['author'] . '</font>' . ", Posted on: " . $row['date'] . '<p>';
            echo '<p>' . $row['body'] . '</p><br />';
        }

    else:

        echo '<p>We are really very sorry, this page does not exist!</p>';

    endif;
}

And I am using this code to dispaly it on my index.php page…

<?php
    if (isset($_GET['id'])) :
        $obj -> get_content($_GET['id']);
    else :
        $obj -> get_content_summary();
    endif;
?>

Any suggestions how to do this? And can we do this by using .htaccess?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:41:31+00:00Added an answer on May 25, 2026 at 5:41 pm

    The unfortunate thing about using mod_rewrite is that the data you are supplying in the form of a url is not the best way to query a database. But none the less you have year, month, day and title variables so you will need to rewrite your get_content function to query soomething like (depending on how you date is stored in the database.):

    select * from cms_content 
       WHERE date='mktime(0,0,0,$month,$day,$year)'
       AND title='$title'
     ORDER BY id DESC
    

    .htaccess would be something like:

    RewriteRule ^(.*)/(.*)/(.*)/(.*)$  index.php?year=$1&month=$2&day=$3&title=$4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my website: http://www.jrbaldwin.com I'm having a problem of my left sidebar getting
I recently ran the database repair tool as per this link: http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/db-repair-tool At the
On this website http://www.contrastrebellion.com/ about half way through there is a circle that rotates
Background: Suppose I have a website that is hosted on http://www.example.com and the site
I have developed a news portal website (in French): http://www.monde-presse.com I'm encountring small issues
i want to do a website wich is having search functionality. in this i
Lets take the example from Yelp: http://www.yelp.com/boston You can see that it's a website
Having this route: map.foo 'foo/*path', :controller => 'foo', :action => 'index' I have the
After having this question answered through a link to an external site , I
I'm having problems trying to connect my website to Facebook. What I would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.