I need an idea to do this - Testimonial manager

Discussion in 'PHP' started by mantero, Nov 27, 2010.

  1. #1
    lets say I have a db data like this:

    id | Testimonials
    =====================
    1 | this is tesmonial 1
    ---------------------------
    2 | this is tesmonial 2
    ---------------------------
    3 | this is tesmonial 3

    I want to make something like a "token"(I'm not sure what to call it)..which user can add in wysiwyg editor like this:

    [testimonial,3]

    then the output will display "this is tesmonial 3"(depend on id)

    how is it possible to do this using php?

    a simple code explanation would be help

    thanks alot!
     
    mantero, Nov 27, 2010 IP
  2. beven

    beven Well-Known Member

    Messages:
    483
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    113
    #2
    you are looking to make a code to find out the exact No. searched by someone?
     
    beven, Nov 27, 2010 IP
  3. mantero

    mantero Well-Known Member

    Messages:
    612
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    110
    #3
    no, Im looking a way to replace an input by a user, then replace the output using the data from database.

    I know it can be done using str_replace, but the output is called from database

    You get what I mean?
     
    mantero, Nov 27, 2010 IP
  4. drctaccess

    drctaccess Peon

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    0
    #4
    $token = '[testimonial,3]';
    preg_match('/[0-9]/', $token, $matches);
    if($matches[0])
    {
    $sql = 'SELECT * FROM table WHERE ID=' . $matches[0];
    $result = mysql_query($sql);
    $row = mysql_fetch_array($result);
    echo $row['testimonial'];
    }

    I hope this one helps
     
    drctaccess, Nov 27, 2010 IP