Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing a variable upon refresh

Status
Not open for further replies.

kawnz

Technical User
Jan 30, 2003
67
US
I made a script that displays flash cards, and it automatically refreshes the page after so many seconds.

What I want to do now, is have the answer to the previous flash card problem, show in the top left corner of the card, while it shows a new problem in the middle of the card.

see card image below : it displays 42 (from previous 6x7)
and then a new question in the middle

================
| 42 | | |
================
| | | |
| | 8 x 3 | |
| | | |
================
| | | |
================

I have it work out the answer after it generates the numbers, and then want to include the answer value in the refresh.

I want it to generate flash.php?ans=24 for the next reload

How do I do that?
 
I figured out a way to do it
I have it write the answer to a file (ans.htm), overwriting the existing ans.htm file

$fileb = fopen("flash/ans.htm","w");
fwrite($fileb, $ans);
fclose($fileb);

In the page code itself, I have it include ans.htm in the little box in the top left

That way, it always writes the new answer, and always calls the previous answer before writing the new one.

Thanks for the help I know you would have provided :)
 
You do realize that if two users are accessing this at the same time, there would be a race condition, right? //Daniel
 
LOL, I guess I didn't think of that. How do I get the desired effect then?
 
Something like
[tt]header('Refresh: page.php?ans=' . $answer);[/tt]
doesn't work for you? //Daniel
 
Whoops, I was thinking in [tt]Location[/tt] syntax... The correct line would be
[tt]header('Refresh: <seconds>;url=page.php?ans=' . $answer);[/tt] //Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top