Hi guys i have sending a message to customer mobile like this
$message="Your ticket is booked for ID='$id'";
So now my boss tell me that we need a provision to customize this message.may be like this
$message="Your ticket ID='$id' is booked,you are welcome";
They will change the message simultaneously. So i add a part in admin to change that message using text area.But what i do with that variable $id
? How i add variable to database and fetch that?
Save your message in database like this
$message="Your ticket ID= ###id### is booked,you are welcome";
And while getting the data from database
$message = //message from db
str_replace("###id###", $id, $message);
Hope it helps
Cheers
My suggestion would be to use a placeholder for that. As input, you could for instance define a %ID%
placeholder, and replace that dynamically when you retrieve the message from your database.
For example, when your boss enters the message "Your ticket is booked for ID=%ID%"
, you replace %ID%
with the real ID in your PHP script.
$message="Your ticket ID = {{ id }}is booked,you are welcome";
$message = str_replace("{{ id }}", $id, $message);
echo $message;
Here I suggesting the same as vaibhav but more visible format
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.