Display query result in a table

后端 未结 4 1521
谎友^
谎友^ 2021-01-22 20:01

I have a MySQL query with over 50 return results. Now I need to display the results in a table with 3 rows and 3 columns.

Something like this:



        
4条回答
  •  甜味超标
    2021-01-22 20:49

    use a for-loop to iterate your $mycontent-array:

    EDIT: I was made aware that $mycontent is built differently than I first assumed:

    $h = ""; // we are going to build the table in $h
    
    $maxcount = count($mycontent); // get the number of values within the array 
    
    for ($i = 0;$i < $maxcount;$i++) { // counting $i up from 0 to $maxcount -1 ...
    
       $h.= ""; // build row
    
    }
    
    $h.= "
    {$mycontent[$i]}
    "; // close the table echo $h; // echo it

    ---> live demo: http://3v4l.org/g1E1T

提交回复
热议问题