Jump to content

Old_Dog_New_Tricks

New Members
  • Posts

    3
  • Joined

  • Last visited

Old_Dog_New_Tricks's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I agree, the results from the script are not helpful and not what I expected. I used JS first, and it did what I wanted, but the number generation is far from truly being random - there's obvious patterns to the number order generated, so that's why I was looking at php. This is a first experiment, so I have a bit to learn, obviously, both about php and about even how to correctly prompt the ai to obtain the results for which I'm searching. I appreciate your words of caution, but it's worth noting I'm not trying to solve any world problems so anything I get from the ai is not going to be the cause of a catastrophe. I'm simply playing around and experimenting to obtain some code to take apart. But, again, I appreciate your cautionary warning.
  2. Thank you Barand, your suggestion worked and it printed the results to the same page. It took me a bit of searching but I found I had to install apache and then put the file in my var/www/html folder and call it using localhost/filename. The result from the script in the webpage is not what I expected, but that's another issue/topic and something to play with further before I give up, commence with the gnashing of teech, and beg for further assistance.
  3. Recently I retired and decided to start learning a little about my computer and webpages. I'm doing ok with html and css so I thought I'd look at php. I seem to learn best by examples and then deconstructing those examples, so I asked the openai for a number randomiser based on the user providing a list of numbers, and it spat out some code, but it references an index.php file, and I don't know what to do. Can someone guide me to a solution? Here's my openai prompt: Create a basic webpage with a text box to accept input from the user, and a button to perform the action. Use HTML & PHP, don't use JS or CSS, to allow the user to input a list of numbers, strip out & remove any and all non-number characters, mix and randomise the numbers, then output the numbers in groups of 5 numbers, separated by a single space, sorted from lowest to highest, each group of 5 numbers is to be on its own line, each group separated by a blank line. Here's the provided code: <html> <head> <title>Number Sorter</title> </head> <body> <form action="index.php" method="post"> <input type="text" name="numbers" placeholder="Enter numbers here..."> <input type="submit" name="submit" value="Sort"> </form> <?php if(isset($_POST['submit'])) { $numbers = $_POST['numbers']; $numbers = preg_replace('/[^0-9]/', '', $numbers); $numbers = str_split($numbers); shuffle($numbers); sort($numbers); $numbers = array_chunk($numbers, 5); foreach($numbers as $number) { echo implode(' ', $number) . "<br><br>"; } } ?> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.