php script

Status
This thread has been locked.

Annabella

QUIT - SERIOUS HEALTH ISSUES AND WELL YEAH :/
Banned
Feedback score
17
Posts
229
Reactions
116
Resources
0
so im learning php and kinda confused on this.

how would I make it so for example:
mypatience: 81.4% (random number)
but it auto updates without needing to refresh and doesn't make a new line
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

Jack

Retired Moderator
Supreme
Feedback score
11
Posts
1,210
Reactions
1,462
Resources
0
what is "actual content"
Literally anything.. Here's a template for you
HTML:
<!DOCTYPE html>
<html>
    <head>
        <title>Template</title>
    </head>
    <body>
        <p>mypatience: 81.4%</p>
        <hr>
        <p>yourpatience: 0.0%</p>
    </body>
</html>
 

croissant222

Feedback score
0
Posts
439
Reactions
151
Resources
0
Literally anything.. Here's a template for you
HTML:
<!DOCTYPE html>
<html>
    <head>
        <title>Template</title>
    </head>
    <body>
        <p>mypatience: 81.4%</p>
        <hr>
        <p>yourpatience: 0.0%</p>
    </body>
</html>
upload_2020-4-7_16-35-37.png
upload_2020-4-7_16-35-48.png
that what u want?
 

Attachments

  • upload_2020-4-7_16-35-37.png
    upload_2020-4-7_16-35-37.png
    40.8 KB · Views: 81
  • upload_2020-4-7_16-35-48.png
    upload_2020-4-7_16-35-48.png
    63.9 KB · Views: 81

Tom Croft

Tom Croft - Web Developer
Premium
Feedback score
5
Posts
103
Reactions
64
Resources
0
[DOUBLEPOST=1586294576][/DOUBLEPOST]Tom Croft here u go too funny reacting fool

You're not interpreting the DOM there, you're just echoing random value: $value. What Jack meant is in a fully developed site, you would have to interpret the DOM to change the element's content. Something that PHP cannot do.

Overall point is that technically yes you can stream data like that but it's definitely not in anyone's book of best practices as it's highly impractical in most cases. Using a simple AJAX request and some ol' JS would solve OPs original query as PHP cannot interpret the DOM and therefore cannot edit an element's contents.
 

croissant222

Feedback score
0
Posts
439
Reactions
151
Resources
0
You're not interpreting the DOM there, you're just echoing random value: $value. What Jack meant is in a fully developed site, you would have to interpret the DOM to change the element's content. Something that PHP cannot do.

Overall point is that technically yes you can stream data like that but it's definitely not in anyone's book of best practices as it's highly impractical in most cases. Using a simple AJAX request and some ol' JS would solve OPs original query as PHP cannot interpret the DOM and therefore cannot edit an element's contents.
idk what the first half u said means, if you can stream stuff from backend it dosent have to be a random value u can get something else like from a db or api, the other half of what u wrote is pointless cuz, again i already said i know its not clean or good but it is fully possible
 

Jack

Retired Moderator
Supreme
Feedback score
11
Posts
1,210
Reactions
1,462
Resources
0
[DOUBLEPOST=1586294576][/DOUBLEPOST]Tom Croft here u go too funny reacting fool
There still no data below it, which either:
a) Proves you have no idea what you're talking about or
b) Proves that it is not possible with pure PHP

if you can stream stuff from backend it dosent have to be a random value u can get something else like from a db or api, the other half of what u wrote is pointless cuz, again i already said i know its not clean or good but it is fully possible
Nobody is saying that it doesn't have to be random data. Of course OP isn't trying to output "mypatience" to be some random value.
The point is you're not "updating" any value.. you're just flushing whatever is in the response buffer, until the response completes.
Notice how your page never fully loads? You have to manually click the "cancel" button to make it stop - because the response never completes. And that's why it's not possible to do this if there is anything else on the page below the "mypatience" (because it would follow the 'mypatience' value in the buffer, but since you're using to buffer to output values, you have to make a choice to print more values or print the rest of the page).
 
Last edited:

croissant222

Feedback score
0
Posts
439
Reactions
151
Resources
0
There still no data below it, which either:
a) Proves you have no idea what you're talking about or
b) Proves that it is not possible with pure PHP


Nobody is saying that it doesn't have to be random data. Of course OP isn't trying to output "mypatience" to be some random value.
The point is you're not "updating" any value.. you're just flushing whatever is in the response buffer, until the response completes.
Notice how your page never fully loads? You have to manually click the "cancel" button to make it stop - because the response never completes. And that's why it's not possible to do this if there is anything else on the page below the "mypatience" (because it would follow the 'mypatience' value in the buffer, but since you're using to buffer to output values, you have to make a choice to print more values or print the rest of the page).
there u go now its the same as urs happy lol?

>Notice how your page never fully loads?
dosent matter it dont make what op wants impossible

>but since you're using to buffer to output values,
irrelevant, it could be unbuffered or buffered would work either way just might need an extra line[DOUBLEPOST=1586301730][/DOUBLEPOST]
da proof2.gif

for some reason the previous attachment is not displaying
 

Attachments

  • da proof2.gif
    da proof2.gif
    50.2 KB · Views: 58

Jack

Retired Moderator
Supreme
Feedback score
11
Posts
1,210
Reactions
1,462
Resources
0
there u go now its the same as urs happy lol?

>Notice how your page never fully loads?
dosent matter it dont make what op wants impossible

>but since you're using to buffer to output values,
irrelevant, it could be unbuffered or buffered would work either way just might need an extra line[DOUBLEPOST=1586301730][/DOUBLEPOST]View attachment 330035
for some reason the previous attachment is not displaying
Well I'll give you credit. While one of the jankiest/most broken solutions I've seen (since the page remains in content download permanently), it looks like it does what its supposed to. Sometimes bad solutions are still solutions.
I see the whole DOM is being regenerated based on the text you selected. Are you outputting the whole page repeatedly and doing an html:not( :last-of-type){display:none} or something?

(Still not recommending OP do this.. just use JS like everyone else mentioned. The code I posted should work but PM if you need help)
 

croissant222

Feedback score
0
Posts
439
Reactions
151
Resources
0
Well I'll give you credit. While one of the jankiest/most broken solutions I've seen (since the page remains in content download permanently), it looks like it does what its supposed to. Sometimes bad solutions are still solutions.
I see the whole DOM is being regenerated based on the text you selected. Are you outputting the whole page repeatedly and doing an html:not( :last-of-type){display:none} or something?

(Still not recommending OP do this.. just use JS like everyone else mentioned. The code I posted should work but PM if you need help)
yes basically seemed like the simplest way to do it[DOUBLEPOST=1586303075][/DOUBLEPOST]i can even make it only generate numbers on a button press
 
Last edited:

Xenons

Web Designer & Developer
Premium
Feedback score
3
Posts
305
Reactions
151
Resources
0
The fact that this guy is being even toxic at this point just to prove this is funny

but I wont be adding anything else regarding the code itself since it's already all been said
only thing I will add is, you wont really grow a good reputation if you keep being toxic :)
 
Status
This thread has been locked.
Top