b. How can you format a table output using ADODB in PHP?

When retrieving data from a database using ADODB in PHP, you may want to format the output in a table for better readability. To do this, you can use a loop to iterate through the query results and output each row as a table row (<tr>), with each field as a table data cell (<td>). You can then echo out the table headers and rows to display the data in a tabular format.

// Assuming $rs is the ADODB recordset object containing the query results

echo &quot;&lt;table&gt;&quot;;
echo &quot;&lt;tr&gt;&lt;th&gt;Column 1&lt;/th&gt;&lt;th&gt;Column 2&lt;/th&gt;&lt;th&gt;Column 3&lt;/th&gt;&lt;/tr&gt;&quot;;

while(!$rs-&gt;EOF) {
    echo &quot;&lt;tr&gt;&quot;;
    echo &quot;&lt;td&gt;&quot;.$rs-&gt;fields[&#039;column1&#039;].&quot;&lt;/td&gt;&quot;;
    echo &quot;&lt;td&gt;&quot;.$rs-&gt;fields[&#039;column2&#039;].&quot;&lt;/td&gt;&quot;;
    echo &quot;&lt;td&gt;&quot;.$rs-&gt;fields[&#039;column3&#039;].&quot;&lt;/td&gt;&quot;;
    echo &quot;&lt;/tr&gt;&quot;;
    $rs-&gt;MoveNext();
}

echo &quot;&lt;/table&gt;&quot;;