//this is to echo coloumn names
$table = '<table border="1" cellspacing="10" cellpadding="10" style="width:60%">';
$table2 = "</table>";
$sql2 = "SHOW COLUMNS FROM $tablename";
$query2 = mysqli_query($conn,$sql2);
$tablename = $_POST['db'];
echo $table;
while($row = mysqli_fetch_array($query2)){
echo $row[0] . " ";
}
echo $table2 . "<br /><br />";
// successful in echoing coloumn names
// now i want to echo rows based on the number of coloumns
$countcol = mysqli_num_rows($query2);
$sql = "SELECT * FROM $tablename";
$query = mysqli_query($conn,$sql);
echo $table;
$i = "";
while($row=mysqli_fetch_array($query)){
for($i=0;$1<$countcol;$i++){
echo $row[0];
}
}
echo $table2 . "<br /><br />";
// this doenst get the all the rows based on the no of coloumns
答案 0 :(得分:1)
在最后一个循环中,echo $ row [0]是正确的还是应该是$ row [$ i]