MYSQL - Select specific value from a fetched array

后端 未结 9 1401
青春惊慌失措
青春惊慌失措 2021-01-06 01:45

I have a small problem and since I am very new to all this stuff, I was not successful on googling it, because I dont know the exact definitions for what I am looking for.

9条回答
  •  再見小時候
    2021-01-06 02:43

    If you want to be able to use 2 consecutive results in one loop, you can store the results of the first loop, and then loop through.

    $initial = true;
    $storedId = '';
    
    while($row = mysql_fetch_array($result)) {
    
      $storedId = $row['id'];
    
      if($initial) {
    
        $initial = false;
        continue;
      }
    
      echo $storedId . $row['name'];
    }
    

    This only works for consecutive things though.Please excuse the syntax errors, i haven't programmed in PHP for a very long time...

提交回复
热议问题