Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7174567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:05:00+00:00 2026-05-28T16:05:00+00:00

In my PHP forum i want people to insert pictures just by inserting the

  • 0

In my PHP forum i want people to insert pictures just by inserting the number/ID of the picture (which they can see in an online photoalbum)

I am looking for a function that can read a string from their posts for example

“bla bla and look at this amazing picture [IMG]234[/IMG] isn’t it awesome …”

then finds the picture in a database with the ID 234 and replaces [IMG]234[/IMG] with
<img src = "path/to/image.jpg" />

preg_replace wouldn’t work 🙁 does anyone have an Idea?
thanks for Your help in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:05:01+00:00Added an answer on May 28, 2026 at 4:05 pm

    Your code needs to make a db call to get the path from the ID.

    Use a tag parser or basic regex to match \[img][0-9]+\[/img]. (preg_match)

    Then query your database for the path with the match result as the ID.

    Finally, use str_replace to replace the original “[img]$match[/img]” with

    Example (pseudo, look these functions up first)

    $matches = preg_match_all('\[img][0-9]+\[/img]', $input);
    $output = $input;
    foreach ($matches as $match) {
       $cur = mysql_query("SELECT path FROM table WHERE ID = $match");
       $row = mysql_fetch_array($cur);
       $output = str_replace('[img]'.$match.'[/img]',$row['path'],$output);
    }
    

    Note: this will only work with tags in lowercasse: img and not with IMG, iMG, ImG and so on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an php website with login form and I want every visitors can
I have form that I want people to fill out but if they are
I want to allow people to use PHP inside of a textarea of a
I'm using the PHP SDK for facebook connect. Now, I can log people in
Basically I just want to turn off the button after people purchase the art
I'm writing a php script which will enable people to change the theme of
I have a basic PHP form (a few fields and 2 checkboxes, I want
I have XML in the following form that I want to parse with PHP
In file1.php , I execute file2.php with <form action=file2.php method=POST> Within file2, I want
I want my php formtoemail to CC a copy of the form to the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.