Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a query which retrives two colums of multiple rows from the db.I want it to display this in a table using php,I have to use two dimensional arrays i guess.Please help on how shall i proceed.

while($row=mysql_fetchrow_array($qry))
{
Please guide how to store the columns in the array[][]


}


[Please guide on how to display the result in the display page]
foreach(   )
{
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
184 views
Welcome To Ask or Share your Answers For Others

1 Answer

// store the columns in the array[][]:
$res = array();
while($row=mysql_fetch_array($qry, MYSQL_NUM)) {
    $res[] = $row;
}

// display the result in the display page
echo "<table>
";
foreach($res as $row) {
   echo "<tr>
";
   foreach ($row as $fld) {
      echo "<td>$fld</td>
";
   }
   echo "</tr>
";
}
echo "</table>
";

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...