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
Post a Comment