GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Tech Whats this called? (https://gfy.com/showthread.php?t=1351692)

Publisher Bucks 01-24-2022 08:06 PM

Whats this called?
 
I want to take data from an SQL database and have specific parts of it included on a .php page using a placeholder, something like this:

[title1] - Which inserts the first title in a column, [title8] would insert the 8th title in that same column, anywhere on the page where that placeholder tag is used.
[image1] - Inserts the first image in a column [title28] would insert the 28th image in that same column again, anywhere that placeholder tag is used.

But then further down the same page, I want to be able to use that same placeholder, to pull exactly the same data again.

Does that have a specific name I should be looking for? Ive tried a few Google searches to find what I want but I'm coming up blank :/

sarettah 01-24-2022 08:29 PM

You just do a str_replace in the page. https://www.php.net/manual/en/function.str-replace.php

Pull the text for your page into a string.

Pull your data from the database.

Replace any tags in the data string with the appropriate data.

For example:

Database of people and in there are their first name, last names and age.

We are going to send out multiple letters to various people.

So, here is the text that we are going to use:

"Dear [first_name] [last_name],
We see that you are [age] years old, [first_name]. "

We have that stored in a variable called datastring


Then we pull the data:

Select firstname, lastname, age from data_table

Then we loop through the returned data

while we have data:

Letter=str_replace(array($row['firstname'],$row['lastname'],$row['age']),array('[first_name]','[last_name]','[age]'), datastring);

Each occurrence of [first_name] will be replaced by the data in $row['firstname'], etc.

send the letter

then next letter

That make sense?

You might be able to find other stuff by searching on replacing template tags, things like that. The text is the template and the tags are the fields in the template that designate what to replace.

There are several template systems out there that are pre-canned also.
.

Publisher Bucks 01-24-2022 11:01 PM

I think so, I'll have a play around over the next couple of days, I'm not entirely sure that will do what I'm envisaging though, but it seems usable for something if not this specific piece of code I'm wanting to throw together.

Thanks for the response :)

CurrentlySober 01-25-2022 07:24 AM

I was hoping to find a picture of an unusual looking poo, to which I would have answered 'Delightful'

TheLegacy 01-25-2022 09:09 AM

Quote:

Originally Posted by CurrentlySober (Post 22957846)
I was hoping to find a picture of an unusual looking poo, to which I would have answered 'Delightful'

Is that better?

https://static01.nyt.com/images/2019...superJumbo.png

CurrentlySober 01-26-2022 01:45 PM

Quote:

Originally Posted by TheLegacy (Post 22957882)

That's 'Utterly Delightful' :thumbsup


All times are GMT -7. The time now is 09:00 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123