Results 1 to 5 of 5
  1. #1

    Using a mysql field as a variable in url

    basically i'm making a new site and the db will have fields like

    title,content,section etc

    tile = This is the title

    i want to have links like

    i don't have a problem creating dynamic links in general, i just want to know how can i add "_" for every space. but i only want this to happen in code, the data in the db should stay the same.

    so when a user visits

    i will have some code on index.php

    at this point i want to replace the _ with a space so i could look it up from the db.

    i also need a function that will replace " " to "_" to create dynamic links

    can someone help?

    does it make sence?

  2. #2
    Join Date
    Jun 2004
    Digital Texas
    $query = mysql_query("SELECT title FROM blah");
    $field = mysql_fetch_row($query);

    $field = stristr(' ','_',$field);
    $field = stristr('_',' ',$field);
    $lookup = mysql_query("SELECT title FROM blah WHERE title = '$field'");

    Mess around with that. stristr is the function u want to use, ref: [(str)ing in ((i)nsensitive) (str)ing search]

    The fisrt one is to convert spaces to _, for displaying to whatever, the second one is for converting _ to spaces for DB queries. Hope this helps

  3. #3
    thank you! now i can play around with it!

  4. #4
    Join Date
    Dec 2004

  5. #5
    Join Date
    Jun 2004
    Digital Texas

Posting Permissions

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