How can I echo a field based on the value of another field?
I hope my script can tell you somehow what I want.
$sth = $conn->prepare("SELECT * FROM table WHERE item = '$item'");
$sth->execute();
$row = $sth->fetch(PDO::FETCH_ASSOC);
echo ($row['amount'] WHERE $row['currency'] = 'USD');

This is the script I have created from your ideas.. But it still makes no sense to me that it has to be this stupid. The bottom script with $pdf you can just ignore.
foreach($conn->query("SELECT amount FROM stockpricetable WHERE itemrelation = '$row[itemnumber]'") as $row2) {
if ($row2['exchange'] == '') { $DKK = $row2['amount'];}
if ($row2['exchange'] == 'CHF') { $CHF = $row2['amount'];}
if ($row2['exchange'] == 'EUR') { $EUR = $row2['amount'];}
if ($row2['exchange'] == 'GBP') { $GBP = $row2['amount'];}
if ($row2['exchange'] == 'SEK') { $SEK = $row2['amount'];}
if ($row2['exchange'] == 'USD') { $USD = $row2['amount'];}
}
$pdf->Text(26, 4, 'DKK'.$DKK);
$pdf->Text(26, 8, 'EUR'.$EUR);
$pdf->Text(26, 12, 'GBP'.$GBP);
$pdf->Text(46, 4, 'SEK'.$SEK);
$pdf->Text(46, 8, 'CHF'.$CHF);
$pdf->Text(46, 12, 'USD'.$USD);
it should just be a case of:
Although, this is assuming the code above the if statement fetches the database results correctly, I can’t tell as ashamedly, I still use the deprecated
mysql_*functions.