Display query result in a table

后端 未结 4 1483
谎友^
谎友^ 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:46

    You can store in a variable if u r planning to use it in a function or you can just print it. Either way...

    $q = "SELECT name, address, content FROM mytable"; 
    $r = mysqli_query($dbc, $q); 
    
    $str = "";
    
    while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
        $str .= "";
        $str .= "";
        $str .= "";
        $str .= "";
        $str .= "";
    }
    
    $str .= "
    " . $row['name'] . "" . $row['address'] . "" . $row['content'] . "
    " echo $str;

    There you go!

提交回复
热议问题