Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
01-24-2022, 08:06 PM | #1 |
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana.
Posts: 770
|
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 :/ |
01-24-2022, 08:29 PM | #2 |
I'll make you famous
Industry Role:
Join Date: Oct 2002
Posts: 13,941
|
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. . |
01-24-2022, 11:01 PM | #3 |
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana.
Posts: 770
|
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 |
01-25-2022, 07:24 AM | #4 |
Too lazy to wipe my ass
Industry Role:
Join Date: Aug 2002
Location: A Public Bathroom
Posts: 38,196
|
I was hoping to find a picture of an unusual looking poo, to which I would have answered 'Delightful'
|
01-25-2022, 09:09 AM | #5 | |
SEO Connoisseur
Industry Role:
Join Date: Apr 2003
Location: Brantford, Ontario
Posts: 15,549
|
Quote:
__________________
|
|
01-26-2022, 01:45 PM | #6 |
Too lazy to wipe my ass
Industry Role:
Join Date: Aug 2002
Location: A Public Bathroom
Posts: 38,196
|
|