Will someone please explain to me and assist to convert my old code into the new MySQLi format? I would greatly appreciate it.
This is what my current code:
<html>
<head>
<title>Last 10 Results</title>
</head>
<body>
<table>
<thead>
<tr>
<td>Id</td>
<td>Name</td>
</tr>
</thead>
<tbody>
<?php
$connect = mysql_connect("localhost","root", "root");
if (!$connect) {
die(mysql_error());
}
mysql_select_db("apploymentdevs");
$results = mysql_query("SELECT * FROM demo LIMIT 10 ORDER BY Id");
while($row = mysql_fetch_array($results)) {
?>
<tr>
<td><?php echo $row['Id']?></td>
<td><?php echo $row['Name']?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</body>
</html>
Again I appreciate the assistance.
This is what I have done ( I am so sorry I am such a noob )
<?php
// Database details
$dbhost = 'localhost';
$dbuser = '#';
$dbpass = '#';
$dbname = '#';
$db = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
if($db->connect_errno > 0){
die('Unable to connect to database [' . $db->connect_error . ']');
}
$results = mysqli_query("SELECT * FROM formdata LIMIT 10 ORDER BY id");
while($row = mysqli_fetch_array($results)) {
?>
<tr>
<td><?php echo $row['ID']?></td>
<td><?php echo $row['FullName']?></td>
<td><?php echo $row['Mobile']?></td>
<td><?php echo $row['Email']?></td>
<td><?php echo $row['Province']?></td>
</tr>
<?php
}
?>