Jump to content

Search the Community

Showing results for tags 'page refresh'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. I'm trying to create a code that moves a string array A B C D E around based on the amount specified entered into a field in a form and the direction which is also entered into the form. What I want to do is to make the $newarray equal $array when the page is refreshed and the submit button is hit again. That way A B C D E when moved LEFT by 1 will be B C D E A and then if RIGHT and 2 is entered, you will see E A B C D. I've been struggling to get session working and just ended up more lost. Here is the code I got so far. I would greatly appreciate any help with this. <html> <div style="border:1px solid black;font-weight:bold;"> <div style="border:none;">A B C D E</div> <form method="POST"> <input type="text" name="thebutton"/> <input type="text" name="offset"/> <input type="submit" value="SUBMIT"/> </form> </div> <?php session_start(); if (isset($_POST["offset"], $_POST["thebutton"])) { $shift=$_POST["offset"]; $direction=$_POST["thebutton"]; $counter=0; $array=array('A','B','C','D','E'); if ($direction=="LEFT"){ for($i=$shift; $counter+$shift<5; $i++,$counter++){ $newarray[$counter]=$array[$counter+$shift]; } for($j=0; $j<$shift; $j++){ $newarray[$counter + $j]=$array[$j]; } } if ($direction=="RIGHT"){ for($counter=0,$k=5-$shift; $counter<$shift; $counter++){ $newarray[$counter]=$array[$counter+$k]; } for($j=0; $j<5-$shift; $j++){ $newarray[$counter + $j]=$array[$j]; } } echo $newarray[0]; echo $newarray[1]; echo $newarray[2]; echo $newarray[3]; echo $newarray[4]; } ?> </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.