How to echo out table rows from the db (php)

前端 未结 5 1186
故里飘歌
故里飘歌 2020-11-28 11:35

i want to echo out everything from a particular query. If echo $res I only get one of the strings. If I change the 2nd mysql_result argument I can get the 2nd, 2rd etc but

5条回答
  •  离开以前
    2020-11-28 12:15

    Nested loop to display all rows & columns of resulting table:

    $rows = mysql_num_rows($result);
    $cols = mysql_num_fields($result);
    for( $i = 0; $i<$rows; $i++ ) {
       for( $j = 0; $j<$cols; $j++ ) {
         echo mysql_result($result, $i, $j)."
    "; } }

    Can be made more complex with data decryption/decoding, error checking & html formatting before display.

    Tested in MS Edge & G Chrome, PHP 5.6

提交回复
热议问题