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!
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?
$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