php - mysqli_assoc + json_encode does not return first row -


$sql= "select team_name label, user_id value d_getreal_captains order team_name asc"; $result = $bfit_connect->query($sql); $rows = mysqli_fetch_assoc($result);  while( $rows = mysqli_fetch_assoc( $result ) ) {     $json[] = $rows; } 

this code works expected except not return first record table (i.e. first team_name , user_id). have seen other people have suggested fix of using mysql_data_seek reset row index, know deprecated , fix utilizing current method. , ideas or advice appreciated... thanks.

you're calling mysqli_fetch_assoc() outside of loop popping first result off of result set. aren't using values anywhere can safely remove it.

$result = $bfit_connect->query($sql); $rows = mysqli_fetch_assoc($result); // <-- remove 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -