:bemused: 😕
I am trying to list first 2 column of a table from my database within table. Has th following HTML+PHP.
But it does not show anything in the browser.
Can anybody help me pointing where I am wrong.
Regards.
HTML+PHP Code.
<html>
<head>
<title>PHP Test 2</title>
</head>
<body>
<?php
// Connecting, selecting database
$usr = 'root';
$pwd = 'root';
$host = '155.1.99.98:3306';
$db = 'testdb';
$link = mysql_connect($host,$usr,$pwd) or die("Could not connect: " . mysql_error());
echo 'Connected successfully';
mysql_select_db($db) or die ('Could not select database');
// Performing SQL query
$query = 'SELECT * FROM usercatmst';
$result = mysql_query($query) or die('Query failed in module 3.php: '. mysql_error());
if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
}
// Printing results in HTML
echo "<table bgcolor=\"#BBFFFF\ ">\n";
while ($row = mysql_fetch_row($result)){
$mcatid = $row[0];
echo "\n<tr>";
echo "<td>$row[0]</\td>";
echo "<td>$row[1]</\td>";
echo "\n</\tr>";
}
echo "\n</\table>";
// Free resultset
mysql_free_result($result);
// Closing connection
mysql_close($link);
?>
</body>