I suspect you'll find that
if ($B1 = '1')
doesn't do what you think it does. Hint: In javascript,
=
is the assignment operator,
==
is the check-for-equality operator. ;)
SQL unfortunately, uses a single
=
to check for equality - this confuses many new users when they must use different operators in different languages to perform the same task.
Here's how I'd go about it.
<?php
$userName = 'root';
$password = '';
$pdo = new PDO('mysql:host=localhost', $userName, $password);
$pdo->query("use testjobsdb");
$materials = Array("10A GPO Triple","10A GPO Double","10A GPO Single","10A GPO Double W/extra");
$stmt = $pdo->prepare("select * from Materials where name = :someStockItem");
forEach($materials as $curMaterial)
{
$stmt->bindParam(":someStockItem", $curMaterial);
$stmt->execute();
while ( $dbRow = $stmt->fetch(PDO::FETCH_ASSOC) )
{
echo "<h4>".$dbRow["id"]."</h4><br>" . $dbRow['name'] . "<br>";
}
}
?>