我正在使用c ++开发MySql应用程序。我无法从MySQL表中打印所有记录。 下面的代码只是打印第一列的数据。
// chaganged the array to match your picture.
$items = array('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16');
//used to format the output
echo "<pre>";
for ( $i = 0; $i<count($items) ; $i++ ) {
echo "loop start \n";
// access 1st item
echo $items[$i]."\n";
// based on your example, it seems that you need the item that is 4 places after the first item of the loop
echo $items[$i+4]."\n";
echo "loop end\n";
// we can use mod to check if we have reached the 4th element (index 3), we use $i+1 to check the second element of the loop
if ( ( $i+1 )%4 == 0 ) {
echo "\n---new line---\n";
$i = $i + 4;
}
echo "\n";
}
echo "</pre>";
答案 0 :(得分:1)
抱歉,我的不好想通啊..选择id FROM user - &gt;选择* FROM用户
答案 1 :(得分:1)
您的查询只选择字段ID,它应该是“select * from user”