PHP coder

Status
Not open for further replies.

delta5

Well Known Member
Messages
1,911
Reaction score
5
Points
83
Location
Ohio
Experience
1 year
I'll try to explain this

On my html webpages I want to output text to the body from a php instead of typing it in the html page. Reason being is I want to keep everything clean and run efficiently. I'm also using classes to assign css to each title and another css for the paragraph text.

.bp { margin-left:15px; margin-right:15px; margin-top:15px; margin-bottom: 15px; color: yellow; font-size:24px; text-align:center;
}
.p {
margin-left:15px; margin-right:15px; margin-bottom:15px; color: white; text-indent: 50px;
}
On the index page I have:

<div class="p">text</div>
I want to replace the text with php code that will display text from another file. Anyone know how?
 

alink

Well Known Member
Messages
2,612
Reaction score
26
Points
83
Location
Dudleyville
Experience
1 year
What about something like this

<div class="p" id="x" value=""></div>
Then call a Javascript function to get the text and add it to the div value using getelementbyid()? Sorry I'm not great with web code, I'm a .NET guy lol.
 

delta5

Well Known Member
Messages
1,911
Reaction score
5
Points
83
Location
Ohio
Experience
1 year
What about something like this



Then call a Javascript function to get the text and add it to the div value using getelementbyid()? Sorry I'm not great with web code, I'm a .NET guy lol.
Maybe use php's f code to open/get/write from a .txt to html? Maybe just leave php alone as much as possible? Without a website/forum my vps is using a little under 200mb of ram. Running centos fully updated with the following installed..

nano, wget, sudo, and Zpanel that came with LAMP.

My vps only has 1core, 1gig ram, 50gb ssd, 100mbs link, unlimited bandwidth. If I install mybb my ram usage will prob go up to 700mb?
 

alink

Well Known Member
Messages
2,612
Reaction score
26
Points
83
Location
Dudleyville
Experience
1 year
I only took 1 php class and that was about 4 years ago and havent used it since so I'm sure you know a lot more about it than I do lol. From what I remember, I used php on the server to verify data that was sent over a network to make sure that nothing was changed during transmission. I did a little bit of read/write from file but not much, Im not sure how you would read from a file and then return the text from the server to the client with just html code. I think you need an intermediate communicator like Javascript (maybe CSS, im not sure; minor experience with that as well).

Im not sure what your ram usage is now, or would be with mybb, but 1 gig isnt much for a server. How much traffic do you get?
 

delta5

Well Known Member
Messages
1,911
Reaction score
5
Points
83
Location
Ohio
Experience
1 year
I only took 1 php class and that was about 4 years ago and havent used it since so I'm sure you know a lot more about it than I do lol. From what I remember, I used php on the server to verify data that was sent over a network to make sure that nothing was changed during transmission. I did a little bit of read/write from file but not much, Im not sure how you would read from a file and then return the text from the server to the client with just html code. I think you need an intermediate communicator like Javascript (maybe CSS, im not sure; minor experience with that as well).

Im not sure what your ram usage is now, or would be with mybb, but 1 gig isnt much for a server. How much traffic do you get?
no traffic right now. I just got this vps a few days ago. Also i'm a 100% noob to all of this. It took me an entire day to install centos, update, 'security hardening,' install zpanel, and getting everything to work. I think I had to start over from the very beginning at least 20 times from making mistakes. Traffic is why im rethinking using more php code. mybb will prob eat up a lot of ram. At least my vps plan is easily up-gradable.
 

ryanr

Moderator
Messages
11,342
Reaction score
1,150
Points
558
Location
Melbourne, Vic
Experience
More than 10 years
Make the page php, not html.
Create a variable that is your html output.
At the very end, output the variable to the screen.

Putting php code in html files won't work because php is server side. The server needs to process first.

Will try find an example and post
 

ryanr

Moderator
Messages
11,342
Reaction score
1,150
Points
558
Location
Melbourne, Vic
Experience
More than 10 years
something like this.
Create a file called index.php
then
Code:
<?php
	$bodytext = '';
	$divtext = 'hello world';
	
	$bodytext .= '<html><body>';
	$bodytext .= '<div class="p">'.$divtext.'</div>';
	$bodytext .= '</body></html>';
	
	echo $bodytext;
?>
 

delta5

Well Known Member
Messages
1,911
Reaction score
5
Points
83
Location
Ohio
Experience
1 year
Think i'll just stick to html, css, and java script. I'm currently using java script for a button and paypal link. I think i'm spending enough time as it is in GIMP. Site is still looking generic tho lol.
 
Status
Not open for further replies.
Toggle Sidebar

UV Sterilizers Worth It?

  • Yes

    Votes: 17 27.0%
  • No

    Votes: 6 9.5%
  • IDK - never used one before

    Votes: 40 63.5%




Top Bottom