Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Mar 2011
    Posts
    33
    Thanks
    9
    Thanked 0 Times in 0 Posts

    How to change url structure?

    Ok this is my site http://www.turkish-football.com/ , and when i click on a link it currently comes up as:

    http://www.turkish-football.com/news_read.php?id=315

    now instead of the whole ID thing id rather the name of the article came up, however when i try to do it, it comes up as egemen%20Korkmaz and so on, and doesnt work

    how do i change the URL structure so the article name comes up and not some ID, i hear this is good for SEO as well

    thanks

  • #2
    New Coder
    Join Date
    Nov 2010
    Location
    California
    Posts
    42
    Thanks
    6
    Thanked 2 Times in 2 Posts
    You can make the query get the title rather than the id. You can also use a URL rewrite condition, the that's with an apache script I think.
    Puppet Master + Programming = Eternal Bliss

  • #3
    New Coder
    Join Date
    Mar 2011
    Posts
    33
    Thanks
    9
    Thanked 0 Times in 0 Posts
    i tried getting the query to get the title but it came up with the %20 between the words and didnt work, ill give another shot now, what's the URL rewite condition? would that mean that there would be two links to each article?

  • #4
    New Coder
    Join Date
    Mar 2011
    Posts
    33
    Thanks
    9
    Thanked 0 Times in 0 Posts
    currently the query goes:

    on the home page click each news has a link as the following:
    PHP Code:
    <a href='news_read.php?id=$row[id]'> <img src=admin/mainnewsimg/".$row['photo'] ." alt='$title' width='125' height='85'> </a
    and on the news page where it displays the news:

    PHP Code:
    <?php
    if(isset($_POST['submit']))
    {
    }
        elseif(isset(
    $_GET['id']))
        {    
        
    $result mysql_query("SELECT * FROM news WHERE id='$_GET[id]' ",$connect);

            while(
    $row mysql_fetch_assoc($result))
            {
                
    $title stripslashes($row["title"]);
                
    $summary stripslashes($row["summary"]);
                
    $body stripslashes(nl2br($row["body"]));
                
    $date $row['date'];
                
    $pic $row['photo'];
                
    $id $row['id'];
                
    $date date("d M Y");
    }
    }
    ?>
    and to display the news:
    PHP Code:
        <?php
        
    //display data
            

            
    echo "<h1 class='headline_header_font'>".$title."</h1>";
            echo 
    "<h4 class='date'>$date</h4><hr>";
            echo 
    "<img src=admin/mainnewsimg/$pic alt='$summary' width='275' height='155' class='news_img'>";  
            echo 
    "<p>$body</p>";
            echo 
    "<br>";
        
    ?>

  • #5
    New Coder
    Join Date
    Mar 2011
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts
    The way I worked around this is to replace the spaces in the title with a underscore. The %20 is a space.

    I currently use the rewrite on my site and then also use php to decode the url and transform my links from a easily readable text link to ?=id=somevalue.

    This is a good way I have found to work with this. the underscore is a great for this purpose.

    Feel free to contact me and I can help you out more.

  • #6
    New Coder
    Join Date
    Mar 2011
    Posts
    33
    Thanks
    9
    Thanked 0 Times in 0 Posts
    hmmm even in the url if i replace the %20 with _ it doesn't pull the data from DB, if poss could you post an example of the code used on a link so i can compare,

  • #7
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Quote Originally Posted by TurkzZ View Post
    hmmm even in the url if i replace the %20 with _ it doesn't pull the data from DB, if poss could you post an example of the code used on a link so i can compare,
    You need to return the underscore to a space before you make your query against the DB.

  • #8
    New Coder
    Join Date
    Mar 2011
    Posts
    33
    Thanks
    9
    Thanked 0 Times in 0 Posts
    ok this whole url structure has confused me, am I meant to change something in the .htaccess file lol, im stumped by this one


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •