Answer to Question #25738 in C++ for Bronue-

Question #25738
Suppose I have a database called HumanResources to which I can connect on server localhost with username “peanut” and password “butter”. Suppose Human Resources has a table called Employee. Write a php page that will connect to this database and print all the rows found in the Employee table to a web page.
1
Expert's answer
2013-03-11T11:14:59-0400
<?php
mysql_connect(localhost, "peanut", "butter");
mysql_select_db("HumanResources");

$data = mysql_query("SELECT * FROM Employee");
mysql_close();

$colCount = mysql_num_fields($data);

echo "<table>\n";
echo "\t<tr>\n";
echo "\t\t<td colspan='$colCount'>Employee table</td>\n";
echo "\t</tr>\n";

while ($row = mysql_fetch_row($data))
{
echo "\t<tr>\n";
foreach ($row as $cell)
echo "\t\t<td>$cell</td>\n";
echo "\t</tr>\n";
}
echo "</table>"
?>

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS