<?php
/* Access to the databse via link commands requires the $link statement
in order for them to be successful, also the term "localhost" stops the $link
failing in the event of a change in your IP Address.*/
$link = mysqli_connect("localhost" , "user", "password", "DbName");
?>
// CONNECTION AND SELECTION VARIABLES FOR THE DATABASE
$db_host = "localhost";
$db_name = "DbName";
$db_user = "user";
$db_word = "password";
// OPEN A CONNECTION TO THE DATA BASE SERVER AND SELECT THE DB
$mysqli = new mysqli($db_host, $db_user, $db_word, $db_name);
// DID THE CONNECT/SELECT WORK OR FAIL?
if ($mysqli->connect_errno)
{
$err
= "CONNECT FAIL: "
. $mysqli->connect_errno
. ' '
. $mysqli->connect_error
;
trigger_error($err, E_USER_ERROR);
}
<?php
$query = "select `partID`, `partDescription`, `qtyInStock`, `sales42D`, `sales14D`, `supplierCompany`, `itemCost` FROM inventory";
if ($result=mysqli_query($link, $query)) {
while ($row = mysqli_fetch_array($result)) {
?>
<tr>
<td><?php echo $row['partID'];?></td>
<td><?php echo $row['partDescription'];?></td>
<td><?php echo $row['qtyInStock'];?></td>
<td><?php echo $row['sales42D'];?></td>
<td><?php echo $row['sales14D'];?></td>
<td><?php echo $row['supplierCompany'];?></td>
<td><?php echo $row['itemCost'];?></td>
</tr>
<?php
}
} else {
echo "It failed!";
}
?>
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
This award recognizes an author who contributes the highest volume of original works or content. Recipients of this award produce extremely valuable content that prioritizes accuracy, relevancy, and professionalism.