Mysql fetch array, table results

后端 未结 6 1861
名媛妹妹
名媛妹妹 2021-01-14 10:07

i\'m pretty new to this and not sure how should i do it,

I\'ve got a database with a column called \"names\"

how can i make it display in so?



        
6条回答
  •  攒了一身酷
    2021-01-14 10:25

    Lets say you have an array of the names called $names, then you could do what you wanted with code that looks something like this:

    
    $name";
    }
    ?>
    
    

    That would put all the names on the same row.

    In order to start a new row say, every 3 names, you could put an if statement in the for loop like this:

    // assume we have these variables available.
    $row_number;
    $max_cols = 3;
    
    // this goes at the top of the foreach
    if($row_number % $max_cols == 0) {
        print '';
    }
    

提交回复
热议问题