title: Linked list from user input php
body: <pre><code> public $head = null;
  public $size = 0;
  
  function push($value, $pos)
  {
      if($pos&gt;0 &amp;&amp; $pos&gt;$this-&gt;size)
      {
          return false;
      }
      else{
          $node = new Node($value);
          if ( $pos == 0) {
              $node-&gt;next=$this-&gt;head;
              $this-&gt;head= $node;
              $this-&gt;size++;
          } else {
              $current = $this-&gt;head;
              for ($i = 0; $i &lt; $pos; $i++) {
                  $previous = $current;
                  $current = $current-&gt;next;
              }
              $node-&gt;next = $current;
              $previous-&gt;next = $node;
              $this-&gt;size++;
          }
      }
  
  }
  
   function pop($pos)
  {
      $current=$this-&gt;head;
      if($pos==0)
      {
          $this-&gt;head=$current-&gt;next;
      }
      else{
  
          for($i=0;$i&lt;$pos;$i++)
          {
              $previous=$current;
              $current=$current-&gt;next;
          }
  
          $previous-&gt;next=$current-&gt;next;
  
      }
      $this-&gt;size--;
  
  }
  </code></pre>
  
  <p>pushing value is working fine, but poping is not working,excuting pop() method and deleting value from database at the same time.stuck please help.
  deleting value from database is easy but the order of linked list get unsorted and push method does not work.
  deleting value of pos=0 will delete pos=0 from database and pos will start from pos=1 and push method is not excuting.</p>