<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>database connections</title>
</head>
<body>
<?php
$link = mysql_connect('website.hostingmysql.com', 'user_name', 'password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_select_db(people);
//execute the SQL query and return records
$result = mysql_query("SELECT * FROM persons");
?>
<table border="2" style= "background-color: #84ed86; color: #761a9b; margin: 0 auto;" >
<thead>
<tr>
<th>Employee_id</th>
<th>Employee_Name</th>
<th>Employee_dob</th>
<th>Employee_Adress</th>
<th>Employee_dept</th>
<td>Employee_salary</td>
</tr>
</thead>
<tbody>
<?php
while( $row = mysql_fetch_assoc( $result ) ){
echo
"<tr>
<td>{$row\['id'\]}</td>
<td>{$row\['title'\]}</td>
<td>{$row\['description'\]}</td>
<td>{$row\['type'\]}</td>
</tr>\n";
}
?>
</tbody>
</table>
<?php mysql_close($connector); ?>
</body>
</html>
mysql_select_db(people);
should bemysql_select_db('people');
It looks like you have error reporting off - there are errors that you should be seeing on this page that are not showing.<?php
error_reporting(E_ALL);
?>
<?php
error_reporting(E_ALL);
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>database connections</title>
</head>
<body>
<?php
$mysqli = new mysqli('website.hostingmysql.com', 'user_name', 'password', 'people');
if ($mysqli->connect_error) {
die('Connect Error (' . $mysqli->connect_errno . ') '
. $mysqli->connect_error);
}
echo 'Connected successfully';
//execute the SQL query and return records
$result = $mysqli->query("SELECT * FROM persons");
?>
<table border="2" style= "background-color: #84ed86; color: #761a9b; margin: 0 auto;" >
<thead>
<tr>
<th>Employee_id</th>
<th>Employee_Title</th>
<th>Employee_Description</th>
<th>Employee_Type</th>
</tr>
</thead>
<tbody>
<?php
while( $row = $result->fetch_assoc() ){
echo
"<tr>
<td>{$row['id']}</td>
<td>{$row['title']}</td>
<td>{$row['description']}</td>
<td>{$row['type']}</td>
</tr>\n";
}
?>
</tbody>
</table>
<?php $mysqli->close(); ?>
</body>
</html>
Secondly - when you say you want your types on different pages - how does that work - do you have to click a link for the type to see those types?
Firstly - you are using the MySQL library - which has been deprecated. Consider moving over to MySQLi
Secondly - when you say you want your types on different pages - how does that work - do you have to click a link for the type to see those types?
Thirdly, your column definitions in your <thead> don't seem to match the rows you are creating
Forth, why are you escaping your array brackets i.e.
Open in new window
Should beOpen in new window
The { } containers in the string will sort out the insertion of the variable for you.Lets concentrate on these things first.