How can I use mysqli_fetch_array() twice?

前端 未结 4 1007
予麋鹿
予麋鹿 2020-12-01 17:55

I am using the entries of a db to fill a row and a column in a table. But I cannot access the SQL returned data twice using mysqli_fetch_array() twice. This doe

4条回答
  •  不知归路
    2020-12-01 18:14

    Yes. mysqli_fetch_array() moves the pointer forward each time you call it. You need mysqli_data_seek() to set the pointer back to the start and then call mysqli_fetch_array() again.

    So before calling the function a second time, do:

    mysqli_data_seek($db_res, 0);
    

提交回复
热议问题