phpPlay - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of phpPlay.php

  1. <?
  2.     //$userToDisplay = readline('Enter Name:');
  3.     
  4.         $results = array(
  5.     array('year' => '2021', 'name'=>'peter', 'course'=>'coursename one', 'grade'=>'A'),
  6.     array('year' => '2021', 'name'=>'td', 'course'=>'coursename six', 'grade'=>'B'),
  7.     array('year' => '2021', 'name'=>'doe', 'course'=>'coursename five', 'grade'=>'D'),
  8.     array('year' => '2021', 'name'=>'john', 'course'=>'coursename four', 'grade'=>'C'),
  9.     array('year' => '2021', 'name'=>'peter', 'course'=>'coursename THREE', 'grade'=>'D*'),
  10.     array('year' => '2021', 'name'=>'doe', 'course'=>'coursename TWO', 'grade'=>'A*')
  11. );
  12. $first = $results[0]['name'];
  13. //echo $first;
  14.     foreach($results as $result){
  15.         $user = $result['name'];
  16.         $year = $result['year'];
  17.         $course = $result['course'];
  18.         $grade = $result['grade'];
  19.     }
  20.     
  21.     print_r($user);
  22.     print_r($year);
  23.     print_r($course);
  24.     print_r($grade);
  25.  
  26.     ?>
  27.     
  28. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  29.   <label for="fname">First name:</label><br>
  30.   <input type="text" id="firstname" name="fname" value="John"><br>
  31.   <input type="submit" value="Submit">
  32. </form> 
  33.  
  34. <?echo $_POST['fname'];?>
  35.  
  36.     
  37. <div class=''> <!--container-->
  38.   <div class='heading'>
  39.     <h1>Exam Results for <? echo $user?></h1>
  40.   </div>
  41.   <br>
  42.   <div class='content-center'>
  43.     <table class='table-auto mx-auto'>
  44.     <?
  45.         $results = array(
  46.     array('year' => '2021', 'name'=>'peter', 'course'=>'coursename one', 'grade'=>'A'),
  47.     array('year' => '2021', 'name'=>'td', 'course'=>'coursename six', 'grade'=>'B'),
  48.     array('year' => '2021', 'name'=>'doe', 'course'=>'coursename five', 'grade'=>'D'),
  49.     array('year' => '2021', 'name'=>'john', 'course'=>'coursename four', 'grade'=>'C'),
  50.     array('year' => '2021', 'name'=>'peter', 'course'=>'coursename THREE', 'grade'=>'D*'),
  51.     array('year' => '2021', 'name'=>'doe', 'course'=>'coursename TWO', 'grade'=>'A*')
  52.     );
  53. $first = $results[0]['name'];
  54. //echo $first;
  55.     foreach($results as $result){
  56.         echo $result['year'];
  57.     }
  58.  
  59.     ?>
  60.       <thead>
  61.         <tr>
  62.            <td>
  63.             Academic Year
  64.           </td>
  65.           <td>
  66.             COURSE NAME
  67.           </td>
  68.           <td>
  69.             GRADE
  70.           </td>
  71.         </tr>
  72.       </thead>
  73.  
  74.       <tbody>
  75.         <tr>
  76.           <td>
  77.             <? echo $year?>
  78.           </td>
  79.           <td>
  80.            <? echo $course ?>
  81.           </td>
  82.           <td>
  83.             <?echo $grade?>
  84.           </td>
  85.         </tr>
  86.  
  87.         <tr>
  88.           <td>
  89.             2022
  90.           </td>
  91.           <td>
  92.            second name of course goes here
  93.           </td>
  94.           <td >
  95.             A
  96.           </td>
  97.         </tr>
  98.         <tr>
  99.           <td>
  100.             2022
  101.           </td>
  102.           <td>
  103.            second name of course goes here
  104.           </td>
  105.           <td >
  106.             A
  107.           </td>
  108.         </tr>
  109.  
  110.         <tr>
  111.           <td>
  112.             2022
  113.           </td>
  114.           <td>
  115.            second name of course goes here
  116.           </td>
  117.           <td >
  118.             A
  119.           </td>
  120.         </tr>
  121.       </tbody>
  122.     </table>
  123.   </div><!--content-centre-->
  124.   <br>
  125.  
  126.   <div class='band'>
  127.     <a class='hover:text-red-500 text-blue-600 visited:text-purple-600' href=''>Download Results Statement</a>
  128.   </div>
  129.   <br>
  130.   <div class='band'>
  131.     <a class='hover:text-red-500 text-blue-600 visited:text-purple-600' href=''>Barton Peveril Candidate Handbook</a>
  132.   </div>
  133.  
  134. </div><!--closing container-->
  135.  
  136.  
  137. <?php
  138. $results = array(
  139.     array('year' => '2021', 'name'=>'peter', 'course'=>'coursename one', 'grade'=>'A'),
  140.     array('year' => '2021', 'name'=>'td', 'course'=>'coursename six', 'grade'=>'B'),
  141.     array('year' => '2021', 'name'=>'doe', 'course'=>'coursename five', 'grade'=>'D'),
  142.     array('year' => '2021', 'name'=>'john', 'course'=>'coursename four', 'grade'=>'C'),
  143.     array('year' => '2021', 'name'=>'peter', 'course'=>'coursename THREE', 'grade'=>'D*'),
  144.     array('year' => '2021', 'name'=>'doe', 'course'=>'coursename TWO', 'grade'=>'A*')
  145. );
  146. $first = $results[0]['name'];
  147. //echo $first;
  148.  
  149.  
  150. ?>
  151.  
File Description
  • phpPlay
  • PHP Code
  • 21 Jul-2021
  • 4 Kb
You can Share it: