I know that this type of question has been asked before. But it most probably is something to do with the query itself. right now the whole thing is php tagged. and this is where i think I am going wrong. This is a perfectly legit phpmyadmin query and returns desired results:
SELECT sm.stockid, (SELECT price FROM prices WHERE stockid = sm.stockid AND typeabbrev = 'RT') AS RT, (SELECT price FROM prices WHERE stockid = sm.stockid AND typeabbrev = 'TR') AS TR, (SELECT price FROM prices WHERE stockid = sm.stockid AND typeabbrev = 'FL') AS FL, (SELECT price FROM prices WHERE stockid = sm.stockid AND typeabbrev = 'DE') AS DE FROM stockmaster sm
This is the format I have it in:
$query = "SELECT sm.stockid, (SELECT price FROM prices WHERE stockid = sm.stockid AND typeabbrev = 'RT') AS RT, (SELECT price FROM prices WHERE stockid = sm.stockid AND typeabbrev = 'TR') AS TR, (SELECT price FROM prices WHERE stockid = sm.stockid AND typeabbrev = 'FL') AS FL, (SELECT price FROM prices WHERE stockid = sm.stockid AND typeabbrev = 'DE') AS DE FROM stockmaster sm";
This block of code though prints nothing:
$result = mysqli_query($db, $query);
$recordCount = mysqli_num_rows($result);
echo $recordCount;
But in phpmyadmin the query returns the following:
I probably need to escape the single quotes or redo my php tagging. Thank you in advance for any help.