Mysql fetch array, table results

后端 未结 6 1811
名媛妹妹
名媛妹妹 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:22

    You know accomplish this by assigning the row count before you start the variable and few flags to know initialized loop or started/ended loop.

    $i = 1;
    $initFlag = false;
    $flag = "closed";
    while($row = mysql_fetch_array($result)) {
        if($i%3 == 0) $initFlag = false;
        if($flag == "closed" && ($i == 1 || $i % 3 == 1)) { 
            echo ""; $flag = "started"; $initFlag = true; 
        }
    
        echo ''.$row['names'].'';
    
        if(!initFlag && $flag == "started" && $i % 3 ==0) { 
            echo ""; $flag = "closed"; 
        }
    
    
        $i++;
    }
    

提交回复
热议问题