Results 1 to 4 of 4
  1. #1
    Newbie RH&A's Avatar
    Join Date
    September 29th, 2005
    Need php code work
    I have successfully used the script in this thread and converted one of my sites over to a database/datafeed driven site.

    I need help in modifying the above referenced script to:
    • Make a copy of the 'Name' field
    • Parse the new name field and replace any 'spaces' with a 'hyphen'
    • save this new field as a seperate column in the table

    This is so I can use mod/rewrite in the url's.

    Please reply here, or privately at ric at signsbyric dot com with your price.


  2. #2
    Roll Tide mobilebadboy's Avatar
    Join Date
    January 18th, 2005
    Mobile, Alabama
    Ric, than can be handled in your display script.

    Somewhere after your call from the DB and before you print the results....

    Replace yourfield with the column/variable pulled from the DB...

    PHP Code:
    $yourfield str_replace(" ""-"$yourfield); 
    And if you want everything lower case....use this instead

    PHP Code:
    $yourfield strtolower(str_replace(" ""-"$yourfield)); 
    Just a quick reply, be careful what you want to pay for...someone will expect it. Ask for the help first before wanting to shell out money you may not need to. Just a friendly suggestion.

    Shawn Kerr (.com) | Disney World | SEC Football

  3. #3
    Newbie RH&A's Avatar
    Join Date
    September 29th, 2005
    Thanks MobileBadBoy,

    I will give that a try this afternoon. Since I am also using the Name field on the display page below the thumbnail, I would assume that I would use this to leave the original Name field alone, and create a new variable based off of it:

    PHP Code:
     $NameURL strtolower(str_replace(" ""-"$Name)); 

  4. #4
    Affiliate Manager cbsturg's Avatar
    Join Date
    January 24th, 2007
    Lima OH
    Yup, that will work. But you don't HAVE to create the new variable (it might be nice for convenience if you're using the $NameURL in multiple spots), you can just use that block of code in any instance where you use $NameURL.

    For example, if your page looks something like this:

    $NameURL = strtolower(str_replace(" ","-", $Name));
    echo $Name;
    echo $NameURL;

    you could eliminate the second variable all together like so:
    echo $Name;
    echo strtolower(str_replace(" ","-", $Name));

    No change to the variable $Name has taken place. This works in SQL statements as well so that

    $query = "INSERT INTO `sometable` (`name1`, `name2`) VALUES ('$Name', '$NameURL')";

    would look like

    $query = "INSERT INTO `sometable` (`name1`, `name2`) VALUES ('$Name', '" . strtolower(str_replace(" ","-", $Name)) . "')";

    Like I said, creating a second variable might be nice for the sake of readability (and especially useful if you're using $NameURL multiple times throughout the script), but it's not necessary. If you're only using the $NameURL once, I probably wouldn't create the new variable, but use the functions Ric pointed out to you on the spot that I wanted that value returned.

    I hope that makes sense...
    Last edited by cbsturg; March 21st, 2007 at 07:04 AM. Reason: small typos...
    Chris Sturgill
    "All my life I've had one dream, to achieve my many goals." - H. Simpson

  5. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. looking for php/mysql work
    By spiderninja in forum Midnight Cafe'
    Replies: 0
    Last Post: January 31st, 2007, 10:12 PM
  2. Which PHP Method will work best?
    By Dan76 in forum Programming / Datafeeds / Tools
    Replies: 10
    Last Post: March 18th, 2006, 11:35 AM
  3. php code
    By tvcrazyman in forum GoldenCAN
    Replies: 4
    Last Post: January 19th, 2006, 04:22 PM

Posting Permissions

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