Click here to Skip to main content
15,891,633 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey,


Basically. I want to echo or print keys.

Example of text file (or database) containing keys:
KEY1
KEY2
KEY3
KEY4
KEY5
KEY6
KEY6

What I want to do is echo or print one key at a time when a button is pressed.

So I press button and it echos KEY1 then i press button again and it echos KEY2, etc.

How can I make this using php?

I don't mind storing the keys in a database either rather than a file.

Thanks.

What I have tried:

I have tried some solutions I found on internet, none that worked the way I wanted them to sadly.
Posted
Updated 2-Jul-18 1:25am

Your question is not clear, but the following will go some way to what you want.
PHP
<?php
    $start = 1;
    $max = 5;
    for($i = $start; $i <= $max; $i++) {
        print("KEY" . $i . "\n");
    }
?>
 
Share this answer
 
Comments
Member 13891475 1-Jul-18 15:39pm    
What is it that you don't understand?

Basically, I want it so that when a user presses a button it echos a key from my database or text file in order. So when he presses once it echo key1, when he presses again it echos key2 etc. and it will never echo the same key, so if key1 has been echoes it will remove itself from the textfile / database.
Member 13891475 1-Jul-18 15:41pm    
And I'll be putting in the keys into the databse / textfile.
Richard MacCutchan 2-Jul-18 3:30am    
OK, so you need the following:
- a database or file to hold all the values
- a button handler to read the next value
- code to display the current value
- some method of removing the current value from the database (DELETE) or text file (write)
USE THIS FOR PRINTING


<?php
if ($_POST) {
echo '<pre>';
echo htmlspecialchars(print_r($_POST, true));
echo '</pre>';
}
?>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900