Avatar of rgb192
rgb192Flag for United States of America asked on

substitute [name] for name in database

template input textbox

where
[name]
is
name of person in database

and
[address]
is
address of person in the database


what is the best way to implement this
PHP

Avatar of undefined
Last Comment
ramelong

8/22/2022 - Mon
ramelong

I 'm not sure that I understand the question...

If you need to replace some maks of a template, I suggest to use
str_replace()

Open in new window

If are you looking for another thing, let me know.
Marco Gasi

I'm sure to not understand this question :-) Leaving jokes, it seems you want to replace the real name and the real address with masks '[name]' and '[address]'. If you know exactly what is the name and specially what is the address you can use str_replace. But if you have no idea about name and address because you get them from an user input, then you could use some regexp.
If you can be more descriptive, we will sure help you better.

Cheers
ASKER
rgb192

yes, I do not know the actual name and address

it is user input

but the user would input   [name]
and expect to see [name] from the database in html after the form has posted
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ramelong

And when you will replace [name] by the real name?
Or... are you traing to replace a string stored into a TEXT field in a DB?
In this case you can follow this steps:
1- Get this text into a string variable (SELECT).
2- Replace [name] with the real name using str_replace().
3- UPDATE the DB record with the new string.
Marco Gasi

I still don't understand what you're trying to do... There is a database? Or simply you wish grab tha user's name from posted variable and print out it in the next page? But this is very easy, I'm sure you know how to do it. Or you wish store for all the session. Please, rgb, be less cryptic and more descriptive. It's impossible to help you without understanding what exactly are you doing...
ASKER
rgb192

>>And when you will replace [name] by the real name?
yes

every time there is [name]

I want to replace with

select name from orders where orderid=700
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
ramelong

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
rgb192

thanks
ramelong

You're welcome!